javascript - jQuery combogrid 在选择一行时识别输入框
问题描述
我正在使用 combogrid https://github.com/powderblue/jquery-combogrid在键入时显示建议。
$(".stresses").combogrid({
url: '/index/stresssearch',
debug: true,
colModel: [{'columnName': 'id', 'hidden': true, 'width': '1', 'label': 'id'},{'columnName': 'name', 'width': '39', 'label': 'Name'}],
select: function (event, ui) {
$(this).val(ui.item.email);
return false;
},
});
在上面关于选择一行的代码中,我需要将该值分配给输入框。输入框是使用 jQuery 动态生成的。如何识别select
函数内的输入框?$(this).val()
不管用。
解决方案
我通过添加 jQueryon
函数解决了它。
$('body').on('focus', '.dynstresses', function () {
$(this).combogrid({
url: '/index/stresssearch',
debug: true,
colModel: [{'columnName': 'id', 'hidden': true, 'width': '1', 'label': 'id'},{'columnName': 'name', 'width': '39', 'label': 'Name'}],
select: function (event, ui) {
$(event.target).val(ui.item.name);
return false;
},
});
});
推荐阅读
- r - 将 R 数据帧写入信息图可读 JSON 文件
- ios - 委托总是在动态框架类中获得零值
- wordpress - 从functions.php短代码调用类函数
- ruby-on-rails - 将附加字段动态添加到 rails 表单
- visual-studio-code - VS 代码自动补全自定义
- javascript - Chart.js 无法读取未定义的属性“fontSize”
- google-analytics - 如何将 Google Analytics(分析)自定义维度设置为数据洞察报告中的维度过滤器?
- forms - 如何在 xamarin 表单的一个内容页面上添加多个选项卡式页面?
- ios - 扩展应用程序和主机应用程序之间的 React-native 通信
- python - OpenCV 断言以负值失败