How to wait for the full load of a bootstrap modal-dialog loaded with jquery .load() function -
i have severals bootstraps modals in website, , load them :
function modal_density(){ $("#modal-content").load("pages/modals/density_control.php"); $('#all_modal').modal('show'); }
then close them :
function close_modal(){ $("#modal-content").empty(); $('#all_modal').modal('hide'); }
i want put focus in input of modal, think modal not loaded when try :
function modal_density(){ $("#modal-content").load("pages/modals/density_control.php"); $('#all_modal').modal('show'); $("#element").focus();//<----added part }
how wait full load of elements ?
[edit]: tryed , doesn't work :
function modal_controle_densite_valid(){ $("#modal-content").load("pages/modals/controle_densite_validation.php", function() { $('#all_modal').modal('show'); $("#codebarre").focus(); }); }
but following code working after 2 sec :
function modal_controle_densite_valid(){ $("#modal-content").load("pages/modals/controle_densite_validation.php", function() { $('#all_modal').modal('show'); settimeout(function() {$("#codebarre").focus()}, 2000); //$("#codebarre").focus(); }); }
the load()
method has second parameter allows provide function should executed whent ajax request completes. try this:
function modal_density(){ $("#modal-content").load("pages/modals/density_control.php", function() { $('#all_modal').modal('show').on('shown', function() { $("#codebarre").focus(); }); }); }
Comments
Post a Comment