mardi 24 février 2015

RadioButtonList in Ember

I've reading and trying some codes but nothing has been working like I want i to... this is the code I have right now.


index.html:



<div class="form-group">
<label for="accommodation">3.2. ACCOMMODATION (*)</label> <br />
<div>
{{view Ember.RadioButton name="accommodation" valueBinding='accommodation' selectionBinding="isSelected" value="Not Required"}}
Not Required
</div> <br />
<div>
{{view Ember.RadioButton name="accommodation" valueBinding='accommodation' selectionBinding="isSelected" value="Required"}}
Required
</div>
</div>


View radiobutton.js:



Ember.RadioButton = Ember.View.extend({
tagName: "input",
type: "radio",
attributeBindings: ["name", "type", "value", "checked:checked:"],
click: function () {
this.set("selection", this.$().val())
},
checked: function () {
return this.get("value") == this.get("selection");

if (this.get("selection") == "Required") {
$('#panelAccommodation').style.display = "block";
}

if (this.get("selection") == "Not Required") {
$('#panelAccommodation').style.display = "none";
}

}.property()


What I want from these RadioButtonLists is to be able to retrieve the value of the selected item so I can send it as a POST to a api and to use the selected value to hide/show a div dependidng on the selected value. Any ideas on how to do this?





Aucun commentaire:

Enregistrer un commentaire