如何将工具栏中的按钮设置为禁用

时间:2016-01-20 10:32:59

标签: javascript jquery css uwp winjs

我在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文件,发现了很多禁用标签。是否可以将按钮设置为禁用,就像我在上面添加了其他属性一样?

1 个答案:

答案 0 :(得分: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);
}

P.S

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

如何编辑按钮上的属性呢?我已经使用此功能来编辑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
}

希望有所帮助:)

相关问题