I am trying to get a form field in a rails 3 project to autosave when it changes. I am trying to do this with the following jQuery ajax call:
$j("#list_" + <%= item.list_id.to_s %> + "_item_" + <%=item.id.to_s %>).live("change", function(){ $j.ajax({ beforeSend: function(request) { request.setRequestHeader("Accept", "text/javascript"); }, type: 'POST', url: '<%= list_text_item_path(List.find(item.list_id), TextItem.find(item.id)) %>/update', data: { value: $j(this).val(), id: '<%= item.id.to_s %>', list_id: '<%= item.list_id.to_s %>' }, success: function(){ alert("success"); } }); });
Whenever the text field changes, I get the following error in jQuery:
(c.value || "").replace is not a function
This is like in jQuery-1.5.min.js. I also had the same error with jQuery-1.4.2.min.js. (I upgraded to 1.5 to make sure this helps.)
Any thoughts on where I'm wrong? Thank you very much.
Edit: Oh shit, when I receive my HTML message, I realized that I had a .live () call attached to the div container of the form input element and not the form input element itself. I have a separate problem, but I think I will post this when I find out what might cause it ...
source share