我有一個簡單的代碼示例@http://jsbin.com/ukiwo3/edit爲什麼排序是jQuery UI .sortable()的唯一觸發事件?
它有2個連接列表和一個綁定事件的負載。我很希望我已經錯過了一些簡單的事情,基於http://jqueryui.com/demos/sortable/事件我想我應該看到所有這些事件發生時,我拖動和重新排序問題李。此刻只將日誌排序到控制檯。
任何人都可以告訴我什麼是錯的,以及如何讓其餘的火?
感謝, 丹尼斯
我有一個簡單的代碼示例@http://jsbin.com/ukiwo3/edit爲什麼排序是jQuery UI .sortable()的唯一觸發事件?
它有2個連接列表和一個綁定事件的負載。我很希望我已經錯過了一些簡單的事情,基於http://jqueryui.com/demos/sortable/事件我想我應該看到所有這些事件發生時,我拖動和重新排序問題李。此刻只將日誌排序到控制檯。
任何人都可以告訴我什麼是錯的,以及如何讓其餘的火?
感謝, 丹尼斯
綁定時事件命名有所不同,例如sortstart
而不是start
。 Look at the list of events on the demo page瞭解您的綁定應該是什麼的完整列表。
總體而言,it should look like this:
$(".questions").bind("sortstop", function(event, ui) {
console.log("stop event");
});
$(".questions").bind("sortstart", function(event, ui) {
console.log("start event");
});
$(".questions").bind("sortchange", function(event, ui) {
console.log("change event");
});
$(".questions").bind("sort", function(event, ui) {
console.log("sort event");
});
$(".questions").bind("sortremove", function(event, ui) {
console.log("remove event");
});
$(".questions").bind("sortout", function(event, ui) {
console.log("out event");
});
$(".questions").bind("sortover", function(event, ui) {
console.log("over event");
});
$(".questions").bind("sortupdate", function(event, ui) {
console.log("update event");
});
(不優化,只是顯示事件名稱)
我知道我只需要第二雙眼睛!應該自己發現它。乾杯 – 2010-12-17 03:01:39
@Denis - 歡迎光臨! :) – 2010-12-17 03:03:56
我這樣做,我看到停止事件被觸發:
$('.questions').sortable({
axis: 'y',
connectWith: ".questions",
placeholder: "question-highlight",
stop:function(event, ui) {
console.log("stop event");
}
});
在我看來,這些「事件」是無法通過bind
訪問。
http://docs.jquery.com/UI/Sortable#events - 點擊這裏,查看綁定的例子。 – 2010-12-17 02:56:25