【问题标题】:How to set the button in my toolbar to disabled如何将工具栏中的按钮设置为禁用
【发布时间】:2016-04-26 03:40:20
【问题描述】:

我在我的 Windows 10 UWP winjs 应用程序中创建了一个工具栏,我想禁用一些按钮。

我像这样将属性附加到按钮:

new WinJS.UI.Command(null, { 
    disable: true, 
    id: 'cmdSave', 
    label: 'save', 
    section: 'primary', 
    type: 'button', 
    icon: 'save', 
    onclick: clickbuttonprintout() 
});

我查看了 winjs css 文件,发现了许多禁用的标签。是否可以像我在上面附加其他属性一样将按钮设置为禁用?

【问题讨论】:

    标签: javascript jquery css uwp winjs


    【解决方案1】:

    想通了:

    您选择按钮,将其设置为禁用,然后对其进行处理。

    var thisBtn = document.getElementById('cmdSave');
    thisBtn.disabled = true;
    WinJS.UI.process(btn); //this is key
    

    考虑到这一点,我设置了一个函数,以便向它传递不同的按钮:

    function disableButton(buttonID){
        var btn = document.getElementById(buttonID);
            btn.disabled = true;
            WinJS.UI.process(btn);
    }
    

    附言

    尽管这不是问题的一部分,但它可能会对人们有所帮助。

    如何编辑按钮上的属性呢?我已经制作了这个函数来编辑 winjs 按钮上的任何属性:

    function changeButtonAttributes(buttonId, element, attribute) {
        var btn = document.getElementById(buttonId); //select button
            btn.winControl[element] = attribute; //button.element = attribute
            WinJS.UI.process(btn); //process all
    }
    

    希望有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-20
      • 1970-01-01
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多