Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for resultsList.container #248

Closed
CodeWithOz opened this issue Jun 25, 2021 · 3 comments
Closed

Docs for resultsList.container #248

CodeWithOz opened this issue Jun 25, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@CodeWithOz
Copy link

Is your feature request related to a problem? Please describe.
I can't find any documentation for resultsList.container to know how it works and how it differs from the resultsList.noResults option that was removed in v10. Please add some documentation.

Thoroughly Describe the solution you'd like
The changelog states:

Changed: noResults API to accept boolean instead of Function to be replaced with resultsList.container

This suggests that resultsList.container is the replacement for resultsList.noResults, but there's no documentation for that and in fact resultsList.container has been moved to resultsList.element. I had custom logic that was running in the noResults callback, so a boolean as a replacement is not sufficient for me. How can I regain that functionality?

Please provide a few use cases for this feature

  1. Replacing custom logic that was previously in noResults in v9

Please Describe alternatives you've considered
I don't know of any alternatives.

Additional context
N/A

@CodeWithOz CodeWithOz added the enhancement New feature or request label Jun 25, 2021
@folknor
Copy link

folknor commented Jun 25, 2021

You're correct that the changelog should show that .container was changed to .element.

Hopefully this helps:

resultsList: {
	element: (element, data) => {
		// query = manipulated query
		// results = rendered results, limited by resultsList.maxResults etc
		// matches = all matches from the fetched data
		//const { query, matches, results } = data
		const { query, matches } = data
		if (
			matches.length === 0
		) {
			const result = document.createElement("p")
			result.innerHTML = `No results for "${query}".`
			element.append(result)
		}
	},
	noResults: true,
}

@CodeWithOz
Copy link
Author

CodeWithOz commented Jun 25, 2021

@folknor thanks for your input. The changelog actually does show that container was changed to element, that's part of why the line I quoted is confusing. If container has been removed then I don't see how it can be a replacement for noResults.

Thanks for the code snippet, I'll try that and see if works.

@CodeWithOz
Copy link
Author

@folknor thanks that works. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants