0

我正在尝试创建具有三个按钮的引导框对话框,可以根据某些权限进行切换。

我可以使用所有三个按钮创建对话框,但我不确定如何在我的 javascript 中动态禁用按钮。我可以使用以下内容了解如何禁用 peice fo html:

<c:when test="${ loginDetails.canRender }">

是否可以在我的 javascript 中禁用我的引导框对话框上的按钮:

bootbox.dialog("Do you want to continue ?", [{
    "label" : "render",
    "class" : "btn-success",
    "callback": function() {                        

    }
}, {
    "label" : "overrride",
    "class" : "btn-primary",
    "callback": function() {
        // do nothing
    }
}]);

所以如果我有渲染权限,我希望启用渲染按钮。

任何人?

4

1 回答 1

4

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();
于 2014-05-20T13:04:40.863 回答