i've made some little widget-plugins which are getting applied to eg. a textbox like $("input.txtbox").myTextbox();
now i'm using ajax for dynamically loading content and i was wondering: is there a way to use jquery's live function for auto-applying that plugin to each textbox which will be loaded via ajax?
thanks
You can't use .live()
but you can set up a global ajaxSuccess
or ajaxComplete
handler.
$.ajaxSuccess(function ()
{
$('input.txtbox').myTextbox();
});
You might want to make this more efficient by not re-initializing the plugin on inputs which already have been initialized; something like
$.ajaxSuccess(function ()
{
$('input.txtbox:not(.myTextbox)').myTextbox().addClass('myTextbox');
});