开发者

Javascript events multiplying

I can't see the forest through the trees. I have a contacts tab with a tableView containing rows that can be deleted. If (in the same session) I delete 'n' number of rows, the subsequent events are called 'n' times.

Here is my code. (I tried to pare t开发者_JAVA技巧his down to isolate the problem.)

The specific event that is being duplicated (...triplicated, etc) is ui.contactDestroyed because I am getting multiple AlertDialogs as well as multiple resulting app.updateContacts and ui.contactsUpdated fires in my log.

Thanks for any critiques of my code (related to the issue or not).

Note: According to my server log, the otg.remote.destroyContact XHR is appropriately being sent once for each legitimate request. The otg.remote.getContacts XHR is sent multiple times because it is tied to the culprit, ui.contactDestroyed.


line 197 and line 188 should not be in the eventListener, the way the code is written right now, everytime someone deletes something, you are adding a new eventListener, that is why it is happening multiple times.

Add application wide eventListeners once

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜