jquery - Get Label Value of radio button outside of element -


i have following html/razor of settings view defined el , outside of defined element 3 radio buttons , labels.

settings view

<div id="settingsview" class="cardheader">@resources.decisionsupport.index.timetable   <span id="currentttheader"></span>    <i id="settingsbutton" class="octicon octicon-gear dsttsettingsbutton dsdisabledelement"></i> <span id="selectedsettings"></span> </div> <div class="cardbody">     <div id="calendar"></div> </div> 

radio buttons

<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 , 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' 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 events , clashes</span> </div> 

i have following backbone code console.log(value); in prevsetting function returnsundefined. how can make returns label of radio button? appreciated.

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);             }, 

i have function return correct value, want return value in prevsetting function.

changecaltype: function(e) {         var checkedtype = typeof (e) !== "string" ? $(e.currenttarget).find('input:radio:checked').attr('id') : e;         console.log("checked type = " + checkedtype); 


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -