Skip to content

Commit

Permalink
Fix for Button click issue on #12. Button clicks doesn't trigger noty…
Browse files Browse the repository at this point in the history
….close anymore.
  • Loading branch information
needim committed Mar 23, 2012
1 parent 99ea9e6 commit 947d397
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions js/jquery.noty.js
Expand Up @@ -81,6 +81,11 @@
// Bind close event to button
$noty.find('.noty_close').bind('click', function() { $noty.triggerHandler('noty.close'); });

// If we have a button we must disable closeOnSelfClick option
if (notification.options.buttons) {
notification.options.closeOnSelfClick = false;
}

// Close on self click
if (notification.options.closeOnSelfClick) {
$noty.find('.noty_message').bind('click', function() { $noty.triggerHandler('noty.close'); }).css('cursor', 'pointer');
Expand All @@ -95,7 +100,7 @@
base.$notyContainer.prepend($noty);

// Bind close event
$noty.one('noty.close', function(event, callback) {
$noty.one('noty.close', function(event) {
var options = $noty.data('noty_options');

// Modal Cleaning
Expand All @@ -115,18 +120,12 @@
$noty.parent().remove();
} else {
$noty.remove();
}

// Are we have a callback function?
if ($.isFunction(callback)) {
callback.apply();
}

// queue render
if (options.layout != 'topLeft' && options.layout != 'topRight') {

// queue render
$.noty.available = true;
base.render();
}

});
});

Expand All @@ -137,7 +136,12 @@

$.each(notification.options.buttons, function(i, button) {
bclass = (button.type) ? button.type : 'gray';
$('<button/>').addClass(bclass).html(button.text).appendTo($noty.find('.noty_buttons')).one("click", function() { $noty.triggerHandler('noty.close', button.click); });
$('<button/>').addClass(bclass).html(button.text).appendTo($noty.find('.noty_buttons'))
.bind("click", function() {
if ($.isFunction(button.click)) {
button.click.apply();
}
});
});
}

Expand Down

0 comments on commit 947d397

Please sign in to comment.