我有這個div在我的軌道查看這使得用戶的集合:更新的HTML5通過屬性的jQuery/AJAX
<div id="users" data-current_page="<%[email protected]_page %>">
<%= render @users %>
</div>
與這個jQuery功能(用於加載上單擊操作更多的用戶)
。$(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;
});
});
爲了增加$( 「#用戶」)ATTR( 「數據CURRENT_PAGE」),我嘗試這樣做:
$("#users").attr("data-current_page").replaceWith(next_page)
ŧ帽子是說如果data-current_page設置爲1點擊它將設置爲2等...但它不起作用。是否有可能通過jQuery更新這個html5屬性?
感謝您的任何想法!
謝謝你的建議我期待到這個 – benoitr 2011-04-06 07:38:26
不客氣,我建議用JS工作時,採取了瀏覽器與JS控制檯,並在它測試你的代碼(我真的很喜歡鍍鉻,它是開發者工具)。 – jcane86 2011-04-06 07:47:01