Reputation: 2577
I've coded my own ModalDialog function, and the popup is working only once. Here's my ModalDialog function:
function ModalDialog(button, text, fadeOut) {
$('.error-notification').remove();
var x = "#" + button;
var $err = $('<div>').addClass('error-notification')
.html(text)
.css('left', $(x).position().left);
$(x).after($err);
$err.fadeIn('slow');
if (fadeOut == true) {
setTimeout(function() {
$err.fadeOut()
}, 3000);
}
//$err.delay(0).fadeOut('slow');
}
And here is the code that is in the script file that masterpage loads.
$(".error-notification").live('click', function () {
$(this).fadeOut('fast', function () { $(this).remove(); });
});
Here is how I am calling the function.
ModalDialog('testingAjax', 'h', false);
I know the ModalDialog function is being called each time, because I used console.log inside the function at the very last. So why is it showing the popup only once and not second/third/fourth time etc...?
Upvotes: 0
Views: 236
Reputation: 3834
You are removing all previously existing popups:
$('.error-notification').remove();
It's actually showing them all, but keeping only the last one. Here's a relevant fiddle: http://jsfiddle.net/BhU6F/3/
Upvotes: 2