In extjs4 How to select tpl's radio button on clicking its value -
i working in extjs4. have tpl view displaying questions , options via radio buttons as-
ext.define('balaee.view.qb.qbqns.qbqnsview', { extend:'ext.view.view', id:'qbqnsviewid', alias:'widget.qbqnsview', store:'qb.qbqnsstore', cls:'qbqnsview', //autoscroll: true, config: { tpl:'<tpl for=".">'+ '<div id="main">'+ '</br>'+ '<b><id="q">{#}.{question}</b>'+ '<tpl for="options">'+ // interrogate kids property within data '<p>  <input type="radio" name="{parent.questionid}" value="{optionid}"> {option}</p>'+ //'<p>  <input type="radio" name="{questionid}"> {option}</p>'+ '</tpl></p>'+ // '<p>---------------------------------------------------------</p>'+ '</div>'+ '</tpl>', itemselector:'div.main' } });
to retrive selected radio buttons,i have written code as-
var qbqnsstore = this.getstore('qb.qbqnsstore'); var qbqnsmodel = this.getmodel('qb.qbqnsmodel'); qbqnsmodel = qbqnsstore.getat(0); var answers = '{"data":['; var = 0; qbqnsstore.each(function (model) { i++; var inputs = document.getelementsbyname(model.get('questionid')); (var j = 0; j < inputs.length; j++) { if (inputs[j].checked) { answers = answers + '{"paperid":"' + papernumber + '","userid":"' + userid + '","questionid":"' + inputs[j].name + '","option":' + inputs[j].value + '},' } } });
so working correctly. user need click on radio button select it. want make functionality such way if user clicks on radio buttons value,it should selected. how perform in extjs4
modify radio output line following:
<p>  <input type="radio" name="{parent.questionid}" id="{parent.questionid}_{optionid}" value="{optionid}"> <label for="{parent.questionid}_{optionid}">{option}</label></p>'+
one note: want make sure id of "{parent.questionid}_{optionid}" unique dom clicking label triggers correct default event form element referencing.
see below info on label tag: https://developer.mozilla.org/en-us/docs/web/html/element/label
Comments
Post a Comment