【问题标题】:Material designs lite: how to update checkbox valueMaterial design lite:如何更新复选框值
【发布时间】:2016-09-03 10:17:33
【问题描述】:

尝试更新 UI 上复选框的状态,但似乎 componentHandler.upgradeElements 对其没有影响。

我也试过componentHandler.upgradeAllRegistered();componentHandler.upgradeElement

Reproduction online

与提供xxxx.MaterialSlider.change(newvalue); 来设置状态的滑块相反,复选框没有类似的东西。

【问题讨论】:

标签: javascript material-design material-design-lite


【解决方案1】:

我通过检查源代码并使用 mdl 包装器而不是输入找到了解决方案。

Reproduction online

也可以在他们的 github 论坛上reported the lack of documentation

具有以下 HTML

<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="demo" id="demoWrapper">
    <input type="checkbox" class="mdl-switch__input" id="demo">
</label>

JS

setTimeout(function(){
    $('#demo').val(true);
    $('#demoWrapper').get(0).MaterialSwitch.on();
}, 1400);

【讨论】:

    猜你喜欢
    • 2015-10-03
    • 1970-01-01
    • 2017-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多