I have some JavaScript below, but it doesn't work unless I have the alert
as shown below. I know this is some sort of timing issue, but I have no idea how to go about fixing it. Any thoughts?
$(function() {
$("#search_field").tokenInput("/searches/suggest_gems.json", {
onAdd: function (item) {
$('#search_field').val(item.name);
// Doesn't work without alert("hi");
},
crossDomain: false,
tokenLimit: 1,
tokenValue: name
});
});