Skip to content

Commit

Permalink
Wait until getModal returns the correct value
Browse files Browse the repository at this point in the history
In response to #53

the function is split to two swal and modalDependant

check getmodal if it returns null or not, if it does return null then
start an interval with 100ms until it does not return null and then call
the modalDependant() function, previously swal
  • Loading branch information
panihans committed Oct 6, 2014
1 parent 71ac716 commit 364d83d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/sweet-alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@
*/

window.sweetAlert = window.swal = function() {
// Copy arguments to the local args variable
var args = arguments;
if (getModal() !== null) {
// If getModal returns values then continue
modalDependant.apply(this, args);
} else {
// If getModal returns null i.e. no matches, then set up a interval event to check the return value until it is not null
var modalCheckInterval = setInterval(function() {
if (getModal() !== null) {
clearInterval(modalCheckInterval);
modalDependant.apply(this, args);
}
}, 100);
}
};

function modalDependant() {

// Default parameters
var params = {
Expand Down

0 comments on commit 364d83d

Please sign in to comment.