Jquery 剑道UI网格单选按钮更改事件未触发?
我有一张剑道表格,上面有一份调查问卷。问题id和问题是使用AJAX调用从数据库中获取的。我在运行时将单选按钮添加到网格中 我的问题是单选按钮没有触发已更改的事件。我的代码如下:Jquery 剑道UI网格单选按钮更改事件未触发?,jquery,kendo-ui,Jquery,Kendo Ui,我有一张剑道表格,上面有一份调查问卷。问题id和问题是使用AJAX调用从数据库中获取的。我在运行时将单选按钮添加到网格中 我的问题是单选按钮没有触发已更改的事件。我的代码如下: <div style="height: 950px;" id="grdQuestions"></div> <div style="text-align: center; margin-top: 10px;">
<div style="height: 950px;" id="grdQuestions"></div>
<div style="text-align: center; margin-top: 10px;">
<button class="k-button" id="submitresults" type="submit">Submit Results</button>
</div>
<script>
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
type: "GET",
url: "/AjaxHandler.aspx?requesttype=getquestions",
dataType: "json",
contentType: "application/json; chartset=utf-8"
}
},
pageSize: 25
});
$("#grdQuestions").kendoGrid({
dataSource: dataSource,
pageable: {
pageSizes: true
},
columns: [
{
field: "QuestionsId",
title: "Question Id",
width:90
},
{
field: "QuestionText",
title: "Question",
width:700
},
{
title: "Not me at all",
template: "<input class='radioq' type='radio' name=" + "'" + "select" + '#: QuestionsId #' + "'" + "id=" + "'" + "notme" + '#: QuestionsId #' + "'" + "/>",
},
{
title: "This is true some of the time",
template: "<input class='radioq' type='radio' name=" + "'" + "select" + '#: QuestionsId #' + "'" + "id=" + "'" + "strue" + '#: QuestionsId #' + "'" + "/>"
},
{
title: "This is true most of the time",
template: "<input class='radioq' type='radio' name=" + "'" + "select" + '#: QuestionsId #' + "'" + "id=" + "'" + "mtrue" + '#: QuestionsId #' + "'" + "/>"
},
{
title: "This is me",
template: "<input class='radioq' type='radio' name=" + "'" + "select" + '#: QuestionsId #' + "'" + "id=" + "'" + "itsme" + '#: QuestionsId #' + "'" + "/>"
}]
});
$("input[type='radio']").on("change", function () {
alert(this.value);
});
});
</script>
提交结果
$(文档).ready(函数(){
var dataSource=new kendo.data.dataSource({
运输:{
阅读:{
键入:“获取”,
url:“/AjaxHandler.aspx?requesttype=getquestions”,
数据类型:“json”,
contentType:“应用程序/json;图表集=utf-8”
}
},
页面大小:25
});
$(“#grdQuestions”)。肯多格里德({
数据源:数据源,
可分页:{
页面大小:正确
},
栏目:[
{
字段:“问题SID”,
标题:“问题Id”,
宽度:90
},
{
字段:“问题文本”,
标题:“问题”,
宽度:700
},
{
标题:“根本不是我”,
模板:“”,
},
{
标题:“有时确实如此”,
模板:“”
},
{
标题:“大多数情况下都是这样”,
模板:“”
},
{
标题:“这就是我”,
模板:“”
}]
});
$(“input[type='radio'])。在(“change”,函数(){
警报(该值);
});
});
使用此选项:用于为动态生成的元素绑定事件
$(document).on("change","input[type='radio']", function ()
{
alert(this.value);
});
你应该用这个
事件委派允许您将单个事件侦听器附加到父元素,该事件侦听器将为与选择器匹配的所有子元素触发,无论这些子元素现在存在还是将来添加。@sony no issues brother:)
$(document).on("change","input[type='radio']", function () {
alert(this.value);
});