使输入上的 disabled 属性与 Meteor 助手反应的最佳方法是啥?

Posted

技术标签:

【中文标题】使输入上的 disabled 属性与 Meteor 助手反应的最佳方法是啥?【英文标题】:What's the best way to make the disabled attribute on an input reactive with Meteor helpers?使输入上的 disabled 属性与 Meteor 助手反应的最佳方法是什么? 【发布时间】:2016-08-06 12:24:52 【问题描述】:

有没有合适的方法来做到这一点?代码如下所示:

<input type="radio"> Answer 1
<input type="radio"> Answer 2

我希望它们都根据集合中的计算来启用和禁用。这个可以吗?

【问题讨论】:

【参考方案1】:

您可以将可选的disabled 属性作为助手传递。

html:

<input type="radio" isDisabled/>

js:

Template.yourTemplate.helpers(
  isDisabled: function() 
    return shouldBeDisabled() ? 'disabled' : '';
  ,
);

【讨论】:

以上是关于使输入上的 disabled 属性与 Meteor 助手反应的最佳方法是啥?的主要内容,如果未能解决你的问题,请参考以下文章