开发者

Handling multiple views via AJAX

开发者 https://www.devze.com 2023-01-05 11:46 出处:网络
I am using AJAX requests (more specifically, jQuery\'s load method) to load diffe开发者_如何学编程rent views within the same HTML DIV.

I am using AJAX requests (more specifically, jQuery's load method) to load diffe开发者_如何学编程rent views within the same HTML DIV.

This works fine, but, some of these dynamically loaded pages have events hooked to them, for e.g. setTimeout, setInterval events, etc.

My question is: How do I handle the loading & unloading of these events across the loading of different views? Is there any specific pattern for this?


The simplest way would probably be to just store data on each registered handler or timeout in an array. When loading a new view, these arrays would be looped and any listeners/timeouts removed before loading the new one.

0

精彩评论

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