Reputation: 3243
Im trying to create bootbox dialog, that has three buttons, which can be switched depending on certain permissions.
I can create the dialog with all three buttons, but im not sure how to dynamically, disable buttons in my javascript. I can find out how to disable a peice fo html using the following:
<c:when test="${ loginDetails.canRender }">
Is it possible to disble my buttons on my bootbox dialog, in my javascript:
bootbox.dialog("Do you want to continue ?", [{
"label" : "render",
"class" : "btn-success",
"callback": function() {
}
}, {
"label" : "overrride",
"class" : "btn-primary",
"callback": function() {
// do nothing
}
}]);
so if i have permission to render, i want the render button enabled.
Anyone?
Upvotes: 0
Views: 2090
Reputation: 156
I had a similar Problem and I found a way to access the Buttons via JQuery.
overrideCreate your bootbox dialog with:
bootbox.dialog({
message: "Do you want to continue ?",
buttons: {
render: {
label: "render",
className: "btn-success",
callback: function() {}
},
overrride: {
label: "override",
className: "btn-primary",
callback: function() {}
}
}
});
Creating the Buttons like that allows you to access the via jQuery Selector e.g.
$('button[data-bb-handler=render]')
(replace "render" with your label)
Now you can hide/show your render button with:
$('button[data-bb-handler=render]').show();
$('button[data-bb-handler=render]').hide();
Upvotes: 4