I am using jqueryui.com’s autocomplete function and I would like it to add the values in a datalist if the input has the list attribute and a remote json source if it has the src attribute.
As far as I can tell I should be able to do:
$(function() {
$( ".keywords" ).autocomplete({
//determine dom object that called this
//if dom object has list attribute
//walk though dataset with id = list attribute
//add to source
//elseif dom object has src attribute
//add url data to source
}
});
});
but I am not very familiar with javascript, how would I extract the dom object, then test it’s attributes?
No, you can’t do it directly like that, but you could do this:
You don’t really need the “field” intermediate to hold the
thisvalue, but I think it makes things a little less confusing in cases like this.