I have this div in my rails view which renders a collection of users:
<div id="users" data-current_page="<%[email protected]_page %>">
<%= render @users %>
</div>
and this jquery function (used to load more users on click action)
$(document).ready(function() {
var current_page = $("#users").attr("data-current_page")
$("a.next").click(function() {
var next_page = ++current_page
$.get("/users.js?page=" + next_page)
$("#users").attr("data-current_page").replaceWith(next_page) # this doesn't work
return false;
});
});
In order to increment $("#users").attr("data-current_page"), I tried this:
$("#users").attr("data-current_page").replaceWith(next_page)
That is to say if data-current_page is set to 1 on a click it will set to 2 etc... but it doesn't work. Is it possible to update this html5 attribute through jquery?
Thanks for any idea!