Javascript 如何使用RadioButtonList并使用Ember获取所选值?

Javascript 如何使用RadioButtonList并使用Ember获取所选值?,javascript,ember.js,Javascript,Ember.js,我是Ember的新手,我正在使用Ember编写一个asp.net web api,在我制作的表单上,我希望能够获得用户选择的值。我该怎么做 我想与Ember一起使用的RadioButtonList之一的示例: <div class="form-group"> <label for="nationalTransportation">3.1. NATIONAL TRANSPORTATION (*)</label> <div

我是Ember的新手,我正在使用Ember编写一个asp.net web api,在我制作的表单上,我希望能够获得用户选择的值。我该怎么做

我想与Ember一起使用的RadioButtonList之一的示例:

   <div class="form-group">
       <label for="nationalTransportation">3.1. NATIONAL TRANSPORTATION (*)</label>
       <div class="radio">
            <label><input type="radio" name="National Transportation" value="Not Required">Not Required</label>
       </div>
       <div class="radio">
            <label><input type="radio" name="National Transportation" value="Public Transportation">Public Transportation</label>
       </div>
       <div class="radio">
            <label><input type="radio" name="National Transportation" value="Own vehicle">Own vehicle (subject to approval)</label>
       </div>
       <div class="radio">
             <label><input type="radio" name="National Transportation" value="Car Rental">Car Rental (subject to approval)</label>
       </div>
   </div>

3.1. 国家运输(*)
不需要
公共交通
自有车辆(需经批准)
租车(需经批准)

为RadioButton列表构建一个视图,如下所示:

App.EventRadioView = Ember.View.extend({

    tagName: 'input',
    type: 'radio',
    attributeBindings: ['type', 'htmlChecked:checked', 'value', 'name'],

    htmlChecked: function () {

        if (this.get('value') === 'Required' && this.get('name') === 'accommodation') {
            $('#panelAccommodation').css("display", "none");
        } else if (this.get('value') === 'Not Required' && this.get('name') === 'accommodation') {
            $('#panelAccommodation').css("display", "block");
        } else if (this.get('value') === 'Required' && this.get('name') === 'flight') {
            $('#panelFlight').css("display", "none");
        } else if (this.get('value') === 'Not Required' && this.get('name') === 'flight') {
            $('#panelFlight').css("display", "block");
        }
        return this.get('value') === this.get('checked');
    }.property('value', 'checked'),

    change: function () {
        this.set('checked', this.get('value'));
    },

    _updateElementValue: function () {
        Ember.run.next(this, function () {



            this.$().prop('checked', this.get('htmlChecked'));
        });
    }.observes('htmlChecked')
});
然后在html中使用它:

{{radio-button checked=model.nationalTransportation value=ntNotRequired}}

试试任何一个无线电插件