I tried to spice up my code with ajax. In fact i want to add ajax to patients/index #patientenajax
<h1>Listing patients</h1>
<div id="patientenajax"><%= render "patienten" %></div>
Next i in application.js i added:
$(function() {
$("#patientenajax th a").on("click", function(){
$.getScript(this.href);
return false;
});
});
And in an new created file index.js.erb:
$("#patientenajax").html("<%= escape_javascript(render 'patienten') %>")
But somehow the ajax or better said the links in #patientenajax th a show no reaction:
<div class="pagination">
<ul>
<li class="prev">
<a rel="prev" href="/patients?page=5">← Previous</a>
</li>
<li>
<a rel="start" href="/patients?page=1">1</a>
</li>..............
I think by default rails-3 uses jQuery 1.9.1 (or that's the least, can't remember!). The live
method was removed in version 1.9
http://api.jquery.com/live/. You should be using on
http://api.jquery.com/on/ instead:
//application.js
$(function() {
$("#patientenajax th a, #patientenajax .pagination a").on("click", function(){
$.getScript(this.href);
return false;
});
});