开发者

How to change passed parameter in custom event

开发者 https://www.devze.com 2023-03-20 09:28 出处:网络
I have a custom event, which rising when new Item created: Event definition $.fn.extend({ OnListItemCreated: function (callback) { $(this).bind(\'OnListItemCreated\', c开发者_如何学Pythonallback);}

I have a custom event, which rising when new Item created:

Event definition

 $.fn.extend({
        OnListItemCreated: function (callback) { $(this).bind('OnListItemCreated', c开发者_如何学Pythonallback);  }
});

When item created, call this:

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

Event handling:

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

How best way to handle newItem and update it?


Actually i had same problem of yours, i needed to handle new elements creation, i used Jquery.liveQuery Plugin, original live() method cannot monitor creation of elements

Sample: (You can do this simply by adding a class to your elements which you want to monitor)

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

精彩评论

暂无评论...
验证码 换一张
取 消