JavaScript error using the :update_elements option
donv opened this issue · 1 comments
donv commented
Hi!
Thanks for a very useful gem!
I am trying to use the :update_elements option, but I am getting an error.
When I try the example given in the README like
:update_elements => {:id => '#id_element', ...}
I get a JavaScript error like this
TypeError: 'null' is not an object (evaluating 'ui.item.id.toString')
The stack trace indicates that the error occurs in autocomplete-rails.js line 90
var data = jQuery(this).data(ui.item.id.toString());
Am I doing something wrong?
donv commented
I found the error. I was not using the "id" field to update any element, and I did not send it in the xhr response. It seems the "id" field is required even if it is not used to update any element.
Sending the "id" field in the xhr response solved the problem.