Skip to content

map: not working with ajax #61

@jayant-lumino

Description

@jayant-lumino

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>'
	}
},
})`
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions