无法在 Ember 操作中使用 jQuery 访问 dom 元素
Can't access dom element with jQuery in an Ember action
我为我的 UI 使用物化并有一个简单的开关
<div class="switch">
<label>
Off
<input id="right-{{item.id}}" type="checkbox" {{action "changeRightForRole" item}}>
<span class="lever"></span>
On
</label>
</div>
在我的 Ember 操作中,我得到了相应的模型(物品)。我的action中要做几件事,但是看起来action取消了开关的默认动画,所以我想这样手动设置。
actions: {
changeRightForRole(params) {
let selector = '#right-'+params.get('id');
console.log(selector);
Ember.$(selector).prop('checked', true);
Ember.$('#right-3').prop('checked', true);
}
}
第一种方式,我动态设置道具的地方不起作用。第二个确实有效。
有什么解决办法吗?
尝试
<input id="right-{{item.id}}" type="checkbox" {{action "changeRightForRole" item preventDefault=false}}>
我为我的 UI 使用物化并有一个简单的开关
<div class="switch">
<label>
Off
<input id="right-{{item.id}}" type="checkbox" {{action "changeRightForRole" item}}>
<span class="lever"></span>
On
</label>
</div>
在我的 Ember 操作中,我得到了相应的模型(物品)。我的action中要做几件事,但是看起来action取消了开关的默认动画,所以我想这样手动设置。
actions: {
changeRightForRole(params) {
let selector = '#right-'+params.get('id');
console.log(selector);
Ember.$(selector).prop('checked', true);
Ember.$('#right-3').prop('checked', true);
}
}
第一种方式,我动态设置道具的地方不起作用。第二个确实有效。
有什么解决办法吗?
尝试
<input id="right-{{item.id}}" type="checkbox" {{action "changeRightForRole" item preventDefault=false}}>