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

map: not working with ajax #61

Open
jayant-lumino opened this issue Mar 16, 2021 · 3 comments
Open

map: not working with ajax #61

jayant-lumino opened this issue Mar 16, 2021 · 3 comments

Comments

@jayant-lumino
Copy link

jayant-lumino commented Mar 16, 2021

Hi, First of all, thank you for this awesome plugin. when I am using your plugin with prefetched data then it is working fine. Showing all the result

`$('.short_code').suggest('#', {
data: text_shortcuts_array,
map: function(text_shortcut) {
	return {
		value: text_shortcut.text,
		text: '<strong>'+text_shortcut.value+'</strong><br>'
	}
},
})`


But when I am using ajax for data things are not working fine for me. I don't know where I am doing wrong

$('.short_code').suggest('#', {
data: function(q, provide) {
	$.getJSON("/someurl", { q: q }, function(data) {

		text_shortcuts = data;
		var text_shortcuts_array = [];

		$.each(text_shortcuts, function (key, value) {
			text_shortcuts_array.push({
				value: value['Textshortcut']['shortcut'],
				text: value['Textshortcut']['text']
			});
		})
		<!-- I am getting value here -->
provide.call(text_shortcuts_array);
	});

},
map: function(text_shortcut) {
	return {
		value: text_shortcut.text,
		text: '<strong>'+text_shortcut.value+'</strong><br>'
	}
},
})`
```
@jayant-lumino jayant-lumino changed the title Map not working with ajax map: not working with ajax Mar 16, 2021
@fawwadshafi
Copy link

"Add delay search while typing" is not working. When I integrate as per the instruction, dropdown box is not showing

@fawwadshafi
Copy link

Also, there is another issue. If we do not use "Delay" then "map" function is not loading getting the Latest records from ajax

@shaneiseminger
Copy link

For what it's worth, I too had trouble with the provide.call() method. But I was able to get it to work by returning a jqXHR promise. So if you need to do some post-processing of the ajax response, you might try wrapping the $.getJSON() call in a JQuery promise, then resolving the promise after post-processing the ajax data.

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

No branches or pull requests

3 participants