Jquery 获取元素外部单选按钮的标签值
我将设置视图的以下HTML/Razor定义为Jquery 获取元素外部单选按钮的标签值,jquery,razor,backbone.js,radio-button,backbone-views,Jquery,Razor,Backbone.js,Radio Button,Backbone Views,我将设置视图的以下HTML/Razor定义为el,在定义的元素之外是3个单选按钮及其标签 设置视图 我确实有另一个函数返回正确的值,但是我也想在prevSetting函数中返回值 changeCalType: function(e) { var checkedType = typeof (e) !== "string" ? $(e.currentTarget).find('input:radio:checked').attr('id') : e; console.
el
,在定义的元素之外是3个单选按钮及其标签
设置视图
我确实有另一个函数返回正确的值,但是我也想在prevSetting
函数中返回值
changeCalType: function(e) {
var checkedType = typeof (e) !== "string" ? $(e.currentTarget).find('input:radio:checked').attr('id') : e;
console.log("Checked Type = " + checkedType);
<div id="settingsRadios">
<div class="radio radio-info radio-inline">
<input type="radio" id="simpleRadio" name="settingsRadio" />
<label for="simpleRadio">@Resources.DecisionSupport.Index.SimpleViewLabel</label>
</div>
<span class="dsSettingsDesc">'Simple' shows suitable and unsuitable timeslots</span>
<div class="radio radio-info radio-inline">
<input type="radio" id="overlayRadio" name="settingsRadio" checked="" />
<label for="overlayRadio">@Resources.DecisionSupport.Index.OverlayViewLabel</label>
</div>
<span class="dsSettingsDesc">'Overlay' some description here</span>
<div class="radio radio-info radio-inline">
<input type="radio" id="detailedRadio" name="settingsRadio" />
<label for="detailedRadio">@Resources.DecisionSupport.Index.DetailedViewLabel</label>
</div>
<span class="dsSettingsDesc">'Detailed' gives information about events and clashes</span>
</div>
var TimetableSettingsView = Backbone.View.extend({
el: "#settingsView",
ui: {
selectedSettings: $('#selectedSettings'),
settingsButton: $('#settingsButton')
},
events: {
'click #settingsButton': 'showSettings'
},
initialize: function() {
var self = this;
this.settingsTpl = _.template($('#timetableSettingsTpl').html());
$(document).on('change', '#settingsRadios', function(e) {
self.changeCalType(e);
});
$(document).on('click', '#selectButton', function() {
self.prevSetting();
});
this.render();
},
render: function() {
this.ui.settingsButton.webuiPopover({
title: "Timetable Settings",
content: this.settingsTpl,
animation: 'pop',
closeable: true,
width: 400,
height: "auto",
placement: "auto"
});
},
prevSetting: function() {
console.log("Button Clicked");
var value = $(":radio[name=settingsRadio]:checked").val();
console.log(value);
},
changeCalType: function(e) {
var checkedType = typeof (e) !== "string" ? $(e.currentTarget).find('input:radio:checked').attr('id') : e;
console.log("Checked Type = " + checkedType);