1

我有一个带有五个菜单栏项的道场菜单栏。在页面加载时,菜单栏项目之一将处于禁用模式。单击“添加”菜单栏项时,必须启用已禁用的菜单栏项(“保存”)。我正在使用以下脚本启用它。但问题是,它不在同一条线上。它在下一行启用。如何解决这个问题。

这是我的道场菜单栏:

<div class="claro" id="menuDiv151" onclick="setWidgetproperty(this.id,'x','navMenu151');" onmousedown="setMenuBarProperty('navMenu151');" onmouseup="setDocStyle(this.id)" style="border:1px dotted white; left: auto; position: absolute; width:450px; top: 620px;">
     <div dojotype="dijit.MenuBar" id="navMenu151" style="font-size:11pt;" title="MenuBar">
          <div dojotype="dijit.MenuBarItem" id="SelectMenu151" onclick="getEventLogUserSelect();setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem">
               <img class="images" id="SelectMenu151" name="Select5.png" onclick="setImgProperty(this.id)" src="images/uploads/select.png" style="height:20px; width:20px;">
               Select
          </div>
          <div dojotype="dijit.MenuBarItem" id="AddMenu151" onclick="getUserAdd();setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem">
               <img class="images" id="AddMenu151" name="Add6.png" onclick="setImgProperty(this.id)" src="images/uploads/add.png" style="height:20px; width:20px;">
               Add
          </div>
          <div dojotype="dijit.MenuBarItem" id="CopyMenu151" onclick="setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem">
               <img class="images" id="CopyMenu151" name="Copy7.png" onclick="setImgProperty(this.id)" src="images/uploads/Terminate.png" style="height:20px; width:20px;">
               Copy
          </div>
          <div dojotype="dijit.MenuBarItem" id="DeleteMenu21" onclick="setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem">
               <img class="images" id="DeleteMenu21" name="Delete8.jpg" onclick="setImgProperty(this.id)" src="images/uploads/cancel.png" style="height:20px; width:20px;">
               Delete
          </div>
          <div dojotype="dijit.MenuBarItem" id="SaveMenu21" onclick="setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem">
               <img class="images" id="SaveMenu21" name="Save9.jpg" onclick="setImgProperty(this.id)" src="images/uploads/save.png" style="height:20px; width:20px;">
               Save
          </div>
     </div>
</div>

以及启用和禁用该项目的脚本:

window.onload = function() {
document.getElementById("SaveMenu21").style.display='none';
};
function getUserAdd(){
document.getElementById("SaveMenu21").style.display='block';
}
4

2 回答 2

1

这是一个示例,显示如何隐藏菜单栏项以及如何禁用菜单栏项

http://jsfiddle.net/cswing/62Jcp/

require(["dojo/ready", "dijit/registry", "dojo/dom-style"], 
  function(ready, registry, domStyle) {

    ready(200, function(){
        var menuItem = registry.byId("saveItemDisabled");
        menuItem.set('disabled', true);

        menuItem = registry.byId("saveItemHidden");
        domStyle.set(menuItem.domNode, 'display', 'none');
    });    
});
于 2013-02-07T13:33:28.213 回答
0

尝试这个

dijit.byId("myElement").attr("disabled", false);
于 2013-02-08T12:58:08.983 回答