【发布时间】:2013-01-07 09:06:00
【问题描述】:
我在 extjs 工作。我正在显示 10 个问题及其相关选项。单击提交按钮时,我想检索选定的单选按钮值。我的视图形式为= QbqnsView.js
Ext.define('Balaee.view.qb.qbqns.QbqnsView',
{
extend:'Ext.view.View',
id:'qbqnsViewId',
alias:'widget.QbqnsView',
//store:'kp.PollStore',
store:'qb.QbqnsStore',
config:
{
tpl:'<tpl for=".">'+
'<div id="main">'+
'</br>'+
// '<b>Question :-</b> {pollQuestion}</br>'+
'<b>Question :-</b> {question}</br>'+
'<tpl for="options">'+ // interrogate the kids property within the data
//'<p>  <input type="radio" name="{optionId}"> {option}</p>'+
'<p>  <input type="radio" name="{parent.questionId}"> {option}</p>'+
//'<p>  <input type="radio" name="{questionId}"> {option}</p>'+
'</tpl></p>'+
'<p>---------------------------------------------------------</p>'+
'</div>'+
'</tpl>',
itemSelector:'div.main',
}
Qbqns.js=
Ext.define('Balaee.view.qb.qbqns.Qbqns',
{
extend:'Ext.form.Panel',
requires:[
'Balaee.view.qb.qbqns.QbqnsView'
],
id:'qbqnsId',
alias:'widget.Qbqns',
title:'Qbqns',
//height:400,
items:[
{
xtype:'QbqnsView',
},
],//end of items square
buttons:[
{
xtype:'button',
fieldLabel:'Vote',
name:'vote',
formBind:true,
text:'submit',
// action:'voteAction',
listeners: {
click: function(btn,e,eOpts) {
var answers =
Ext.core.DomQuery.select("input[type='radio']:checked");
console.log(answers);
}
}
}
]
所以在点击提交按钮时,它给我的价值是'输入,输入,......'。它没有给我实际的期权价值。那么如何检索所选选项的实际价值呢?请帮帮我
【问题讨论】:
-
为什么不用ExtJS的单选按钮组件?
-
感谢先生的回复。但我通过json文件接受问题及其选项来动态生成问题及其选项。那么如何使用单选按钮组件来动态创建问题及其选项呢?你能帮帮我吗
标签: extjs radio-button