2015-07-21 19 views
0

我最近問了一個關於無法單擊表格行並在任何頁面上彈出警告但第一次使用List.js分頁的問題。當使用分頁時,只有表格第一頁上的按鈕是可點擊的 - List.js

這是通過調整我的點擊事件解決:

$('#test-list').on('click', 'tr', function() { 
alert("These work, but the rest don't :(") 
}) 

現在我似乎有與按鈕同樣的問題,但我不知道如何解決的單擊事件。

這是click事件,因爲它位於:

$(".test-button").on("click", function() 
{ alert("These work, but the rest don't :("); 
}); 

這裏有一個codepen這樣你就可以檢查出的問題:

http://codepen.io/cavanflynn/pen/gpdgvj

這可能也是一個簡單的修復,但我不能拿出解決方案。

感謝您的幫助!

回答

0

爲按鈕使用靜態參考結合事件,然後再通過按鈕類這樣的:

$("#test-list tbody").on("click", ".test-button",function() { 
    alert("These work, but the rest don't :(..... but now seems working :) "); 
}); 

工作筆http://codepen.io/anon/pen/XbPpPK

相關問題