Ember绑定一个值 [英] Ember binding a value
本文介绍了Ember绑定一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试在Ember中绑定一个值,这样当我提交我的表单时,在下面的单选按钮列表中选择的值会出现在POST请求中,但是我遇到了一些麻烦你们可以帮忙吗? br $>
查看radio.js:
I've been trying to bind a value in Ember so that when I submit my form the value selected on the following Radio Button List goes on the POST request, but I've been having some trouble can you guys help?
View radio.js:
Ember.Radio = Ember.View.extend({
tagName: "input",
type: "radio",
attributeBindings: ["name", "type", "value", "checked:checked:"],
click: function () {
this.set("selection", this.$().val())
if(this.get("selection") === "acRequired") {
$('#panelAccommodation').css("display", "block");
this.set("selection", "Required");
selectionBinding: "App.event.accommodation"
}
if (this.get("selection") === "acNotRequired") {
$('#panelAccommodation').css("display", "none");
this.set("selection", "Not Required");
selectionBinding: "App.event.accommodation"
}
if (this.get("selection") === "flRequired") {
$('#panelFlight').css("display", "block");
this.set("selection", "Required");
selectionBinding: "App.event.flight"
}
if (this.get("selection") === "flNotRequired") {
$('#panelFlight').css("display", "none");
this.set("selection", "Not Required");
selectionBinding: "App.event.flight"
}
},
checked: function () {
return this.get("value") == this.get("selection");
}.property()
});
Index.html:
Index.html:
<div class="form-group">
<label for="accommodation">3.2. ACCOMMODATION (*)</label> <br />
<div>
{{view Ember.Radio name="accommodation" selectionBinding='accommodation' value="acNotRequired"}}
Not Required
</div>
<div>
{{view Ember.Radio name="accommodation" selectionBinding='accommodation' value="acRequired"}}
Required
</div>
</div>
控制器new.js:
controller new.js:
App.EventsNewController = Ember.ObjectController.extend({
accommodation: "Not Required",
flight: "Not Required",
推荐答案
()。val())
if (this.get( selection)=== acRequired){
().val()) if(this.get("selection") === "acRequired") {
(' #panelAccommodation')。css( 显示, block);
this。 set ( selection, 必需);
selectionBinding: App.event.accommodation
}
if (this.get( selection)=== acNotRequired){
('#panelAccommodation').css("display", "block"); this.set("selection", "Required"); selectionBinding: "App.event.accommodation" } if (this.get("selection") === "acNotRequired") {
( ' #panelAccommodation')。css( display, none) ;
this。 set ( selection, 不需要);
selectionBinding: App.event.accommodation
}
if (this.get( selection)=== flRequired){
('#panelAccommodation').css("display", "none"); this.set("selection", "Not Required"); selectionBinding: "App.event.accommodation" } if (this.get("selection") === "flRequired") {
这篇关于Ember绑定一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文