cowboy / jquery-resize

A resize event for ALL your jQueries!

Home Page:http://benalman.com/projects/jquery-resize-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues using .on(...)

jrdmcgr opened this issue · comments

Is there anyway to bind to elements added after the handler is called?

Using $('body').on('resize', '#selector', myFunction) doesn't seem to work at all.

Using $('#selector').resize(myFunction) works, but it doesn't bind to elements that are added by ajax.

Because browsers don't actually trigger resize events, the jQuery event has to be bound specifically to each element you want to monitor. Event delegation won't work.

Thanks for the explanation. Do you know of any way to work around this issue? I see that the plugin is polling for changes. Would rebinding in this loop be expensive?

I don't know of any way to work around this issue.

I've seen some plugins polling every ~50ms and triggering the resize. It's not expensive if you use it carefully, but not on every element on your page.