-
Notifications
You must be signed in to change notification settings - Fork 29
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
Autocomplete doesn't work #45
Comments
If I've understood correctly you aren't filtering your data! var multiple = $('#multipleInput').materialize_autocomplete({
multiple: {
enable: true
},
appender: {
el: '.ac-users'
},
dropdown: {
el: '#multipleDropdown',
itemTemplate: '<li class="ac-item" data-id="<%= item.id %>" data-text=\'<%= item.text %>\'><a href="javascript:void(0)"><%= item.highlight %></a></li>'
},
getData: function(value, callback) {
var testArray = ["i am a value", "i am another value", "i am the final ultimate mega value"];
var data = testArray.reduce(function(acc, curr, i, arr) {
if (curr.toUpperCase().indexOf(value.toUpperCase()) != -1) {
acc.push({
id: i,
text: curr,
highlight: curr.toUpperCase().replace(
value.toUpperCase(), "<b>" + value.toUpperCase() + "</b>")
});
}
return acc;
}, []);
callback(value, data);
}
}); |
yes you should filter your data
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would I go about getting a functionality similar to the function of a standard autocomplete, which would automatically update the dropdown based on what you enter. In the current method, any data entered in the input is lost to the plugin as it simply pulls all data from the array and displays them.
My current function
var multiple = $('#multipleInput').materialize_autocomplete({ multiple: { enable: true }, limit:5, appender: { el: '.ac-users' }, dropdown: { el: '#multipleDropdown' }, getData: function (value, callback) { // ... callback(value, data); } });
The text was updated successfully, but these errors were encountered: