javascript - is it possible to re-initialize all-plugins for jQuery after ajax call? -
if received ajax response using $.post(...) , $.get(...) or something.
received response html format document , includes jquery plugins.
i know jquery plugin needs reinitialize after ajax response. this
$.get('<ajaxurl>').done(function(response){ $('#some_element').html(response); $('#element1_in_some_element').init_plug_in_1(); $('#element2_in_some_element').init_plug_in_2(); $('#element3_in_some_element').init_plug_in_3(); $('#element4_in_some_element').init_plug_in_4(); .... }); but possible re-initialize plugins after ajax call?
like this
$.get('<ajaxurl>').done(function(response){ $('#some_element1').html(response); $('#some_element1').init_plug_in_all(); }); !!
if bind document, should allow have dynamically added elements on page have plugin automatically applied.
for example
$('.datepickers').datepicker(); will fire on document load, , new elements "datepickers" class not have functionality available.
but if attach this...
$(document).on('load','.datepickers', function() { $(this).datepicker(); }); it apply elements datepickers class, added via ajax
Comments
Post a Comment