2011-05-17 24 views
1

我在litle麻煩試圖獲取有關由jQuery排序的事件的信息。jQuery可排序的事件 - 未定義的參數

我有這樣的代碼工作:

var sortable = $("#datatable-wrapper #example tbody").sortable({ 
     cursor: "move", 
     tolerance: 'pointer', 
}); 

sortable.bind("sortout",function(e, ui) { 
     for(i in e) 
      alert("e."+i+" : " + e.i); 
     for(i in ui) 
      alert("ui."+i+" : " + ui.i); 
     for(i in this) 
      alert("this."+i+" : " + this.i); 
     for(i in $(this)) 
      alert("$(this)."+i+" : " + $(this).i); 
}); 

的問題是:我總是得到這樣的:

e.SomeProp : undefined //same for ui, this, and $(this) 

這說明我這些對象的結構,但這些propertys的定義。我做錯了什麼 ?

提前致謝。

+0

你在'$(document).ready(function(){...})裏面做這個嗎? – iMatoria 2011-05-17 09:26:10

回答

1

您的循環將屬性名稱作爲字符串放入i變量中,但您試圖以字面方式訪問​​,而不是命名屬性,並且該屬性未定義。嘗試使用e[i]按名稱訪問對象屬性。

+0

謝謝你的幫助。我應該把我的JS刷成小號 – Gruck 2011-05-17 12:57:46

相關問題