我使用在運行時獲取的php數據構建了SlickGrid
。將有一個任意數字,所以我使用一個類別指定,並給每個按鈕一個獨特的ID基於我循環它的數據。從SlickGrid按鈕獲取點擊事件
我似乎沒有搞清楚的是如何從每個按鈕中獲取點擊事件並區分事件來自哪個按鈕。
我SlickGrid
列定義如下:
columns.push(
{id: "Service", name: "Service", field: "svcname", sortable: true},
{id: "active", name: "Running", sortable: false, width: 50,
cssClass: "cell-pid", field: "pid", formatter: Slick.Formatters.Checkmark },
{id: "toggle", name: "", width: 50, formatter: togglebuttonFormatter}
);
隨着格式化爲按鈕:
function togglebuttonFormatter(row, cell, value, columnDef, dataContext)
{
var button;
// running or not?
if(dataContext.pid != null)
button = "<center><input class='toggleStop' type='button' id='" + dataContext.svcname + "' value='Stop'></center>";
else
button = "<center><input class='toggleStart' type='button' id='" + dataContext.svcname + "' value='Start'></center>";
return button;
}
我一直試圖讓使用各種
的 點擊事件$(<selector>).click(function() { ... });
無濟於事。我已經使用chrome查找每個按鈕的特定類#id組合(並且嘗試了類的正則表達式),但是我錯過了一些重要的步驟。建議?
選擇你試過哪些?你嘗試'.toggleStop'。 – c0deNinja