Reputation: 186
i'm trying to achieve a simple code with jquery since i'm leanring, but i'm having some trouble with a button not sending an event or/and the jquery are not handling it. This is my code :
<button id="btn_delete" class="btn btn-danger btn-sm">Delete</button>
Jquery :
$(document).ready(function(){
$('#btn_delete').on('click', function(){
alert();
bootbox.confirm("Are you sure ? ", fucntion(answer){
alert('User has pressed ' + answer);
});
});
});
I'm trying to use this BootBox, so if someone can help me or does see an error in my programming, please answer me, thanks you !
Console Output:
Uncaught ReferenceError: getColumnNumber is not defined ListArticles:562 Uncaught ReferenceError: getColumnNumber is not defined ListArticles:642 Uncaught SyntaxError: Unexpected token
Upvotes: 0
Views: 157
Reputation: 96
I notice a typo in the word 'function' here
bootbox.confirm("Are you sure ? ", fucntion(answer){
Once fixed, the event work : http://jsfiddle.net/M3tQ5/ - thanks to Bhavik
You should use your browser console (firefox or chrome is prefered), it's great help when is time to debug javascript code. You can open with pressing F12.
Hope that fix your issue.
Upvotes: 3
Reputation: 1540
You made mistake while writing function in bootbox.confirm("Are you sure ? ", fucntion(answer){
it should be bootbox.confirm("Are you sure ? ", function(answer){
.
And little modification in your code ,
Your button
<button id="btn_delete" class="btn btn-danger btn-sm">Delete</button>
Javascript code ,
$(document).on("click", "#btn_delete", function(e) {
bootbox.confirm("Are you sure ? ", function(answer){
alert('User has pressed ' + answer);
});
});
And i hope you have loaded required js and bootstrap js also.
Upvotes: 0
Reputation: 4904
jQuery Code
$(document).ready(function () {
$('#btn_delete').on('click', function () {
bootbox.confirm("Are you sure ? ", function(answer) {
alert('User has pressed ' + answer);
});
});
});
Adding more to @Richer's answer even alert();
throws an error NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMWindow.alert]
...
Alert must have one argument.. Blank alert can be done using this code alert('');
Hope it helps..!!
Upvotes: 2