Monday, 9 September 2013

Is there a document.ready event for ajax request?

Is there a document.ready event for ajax request?

I am using Backbone View to render some widgets, and they are inserted
into the DOM after being rendered as a standalone element. While some
plugins/widgets work when the element is still 'in the mid air', others
require the element to be part of DOM to function properly. For instance,
in the backbone view's render method, I need to call:
$("#images").slimScroll(); //slimScroll is a jquery plugin that add custom
scrollbar
But this doesn't work. It works only after the Backbone View element is in
the DOM, now my workaround is to call the plugin method after inserting
widget to DOM, but this is very inflexible. So I need an event when an
element is rendered in the DOM, something like document.ready but for Ajax
request. Is there such an event? Or what is the best way to deal with such
situation?

No comments:

Post a Comment