My ui-autocomplete should send ajax request to different path’s.
My script changes this path on change select event. But event do not updates and sends request to old url.
I tried live(), on(), livequery(). nothing works.
How to update event?
My input autocomplete field:
<input class="specialization_names ui-autocomplete-input" data-autocomplete-source="/specializations">
I’m changing data-autocomplete-source
Event I’m binging next way(generated by coffeescript)
_ref = $('.specialization_names');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i];
$(input).on('focus', function() {
return $(input).catcomplete({
source: $(input).data('autocomplete-source')
});
});
}
or change on() to live() or to plugin livequery
This code changing url on select.
var select, _i, _len, _ref;
_ref = $('.resume_scopes');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
select = _ref[_i];
$(select).on('change', function() {
var scope_id;
scope_id = $(this).children("option:selected").attr('value');
return $(this).siblings('.specialization_names').attr("data-autocomplete-source", "/specializations/" + scope_id);
});
}
Is there any way to manually refresh one time an event?
jQuery’s
.dataonly reads from thedata-*attribute once (the 1st time you call.dataon the element to get the value)..attrupdates the attribute on the element, but jQuery’s.datahas cached the value. It you want to update it, try using.datainstead.