Ajax does not work
I am following this Michael Hartl's tutorial about AJAX :
http://railscasts.com/episodes/240-search-sort-paginate-with-ajax
However, my AJAX file does not work into my application. This a probably a
matter of jQuery version (because I tried on another app with the same
jQuery version as Michael Hartl and it worked). It is likely that I have
to change the code in application.js. So I have read the latest comments
about this video and so I tried (in vain) :
in application.js :
//= require jquery
//= require jquery_ujs
//= require_tree .
$(function() {
$(document).on("click","#products th a, #products .pagination a",
function() {
$.getScript(this.href);
return false;
});
$("#products_search input").keyup(function() {
$.get($("#products_search").attr("action"),
$("#products_search").serialize(), null,"script");
return false;
});
});
in index.js.erb
$('#products').html('<%= escape_javascript(render :partial => "products"
%>');
Does anyone have another plan ? Thank you in advance
No comments:
Post a Comment