简体   繁体   中英

Document listener jQuery.each

We have a web app that spits out elements server-side and some through Backbone -- and have a simple jQuery.each() statement that flips through elements on the page and adds/removes certain classes based on size of the component. I'm calling this within an "init" function, but it's obviously not working for any elements that are not on the page when loaded; within the Backbone scope.

I'd rather not re-call this function in each Backbone instance (in-case we end up adding more views that render other items needed by this function) and wanted something like a $(document).on() function to work like I do for normal clicks, hovers, etc. I haven't found any examples on how I could make this work with jQuery.each() , so would appreciate any insight on how I'd go about this. Thanks!

我将使用突变观察者

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM