我有一个自定义事件,当新项目创建时会上升:
活动定义
$.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 :(得分:0)
其实我遇到了同样的问题,我需要处理新的元素创建,我用Jquery.liveQuery Plugin,原来的live()方法无法监视元素的创建
示例:(您可以通过向要监视的元素添加类来实现此目的)
$("[class='mylist']").livequery(function(){
this.CountryId = 1; // handle your element
});