Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Add no Cancel button option #71

Merged
merged 4 commits into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ <h1>Demo</h1>
alert("You cancelled.");
}
});
});</code></pre>
</td>
</tr>
<tr>
<td>No cancellation button</td>
<td><button class="btn btn-primary" id="noCancelButton">Click me</button></td>
<td>
<pre>&lt;button class="btn btn-primary" id="noCancelButton"&gt;Click me&lt;/button&gt;</pre>
<pre class="prettyprint"><code>$("#noCancelButton").click(function() {
$.confirm({
text: "This is a confirmation dialog manually triggered! Please confirm:",
cancelButton: false,
confirm: function(button) {
alert("You just confirmed.");
}
});
});</code></pre>
</td>
</tr>
Expand Down Expand Up @@ -116,6 +132,15 @@ <h1>Demo</h1>
}
});
});
$("#noCancelButton").click(function() {
$.confirm({
text: "This is a confirmation dialog manually triggered! Please confirm:",
cancelButton: false,
confirm: function() {
alert("You just confirmed.");
},
});
});
</script>

</div>
Expand Down
11 changes: 8 additions & 3 deletions jquery.confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
'<h4 class="modal-title">' + settings.title+'</h4>' +
'</div>';
}
var cancelButtonHtml = '';
if (settings.cancelButton) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default the property will not exist right? So the cancel button will disappear when people upgrade

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait you are re-using the "cancel button" label option :) How about updating the documentation of that option in the README: https://github.com/myclabs/jquery.confirm#options ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah indeed, forgot about that.
Will do it asap.

cancelButtonHtml =
'<button class="cancel btn ' + settings.cancelButtonClass + '" type="button" data-dismiss="modal">' +
settings.cancelButton +
'</button>'
}
var modalHTML =
'<div class="confirmation-modal modal fade" tabindex="-1" role="dialog">' +
'<div class="'+ settings.dialogClass +'">' +
Expand All @@ -111,9 +118,7 @@
'<button class="confirm btn ' + settings.confirmButtonClass + '" type="button" data-dismiss="modal">' +
settings.confirmButton +
'</button>' +
'<button class="cancel btn ' + settings.cancelButtonClass + '" type="button" data-dismiss="modal">' +
settings.cancelButton +
'</button>' +
cancelButtonHtml +
'</div>' +
'</div>' +
'</div>' +
Expand Down