2011-07-14 27 views
0

我有一個自定義事件,當新項目創建了上漲:如何更改自定義事件傳遞的參數

事件定義

$.fn.extend({ 
     OnListItemCreated: function (callback) { $(this).bind('OnListItemCreated', callback); } 
}); 

當項目創建的,稱之爲:

dialogListFiled.trigger("OnListItemCreated", newItem); 
    .... need to using UPDATED newItem.... 

事件處理:

myObject.OnListItemCreated(function (newItem) { 
      newItem.CountryId=... 
        ...update some newItem values.... 
     }); 

如何處理newItem並更新它的最佳方式?

回答

0

其實我有同樣的問題你的,我需要處理的新元素創作,我用Jquery.liveQuery Plugin,原來住()方法不能監視元素的創作

樣品:(你可以簡單地通過添加一個類來完成此到你想要監視的元素)

$("[class='mylist']").livequery(function(){ 
    this.CountryId = 1; // handle your element 
}); 
+0

newItem - 不是DOM元素,它是簡單的JS對象。我不需要監控。只調用事件並更新JS對象 – MaxWave

相關問題