如何动态过滤jQuery移动选择表单
How to filter jQuery Mobile select form dynamically
我试图通过使用另一个选择列表来过滤选择列表。问题是,我不能重新加载列表后,它被过滤。因此,如果用户在第一个列表中不小心做出了错误的选择,那么第二个列表中就不会留下任何选项。你可以在下面看到我的代码,谢谢。
$('#selectCftDialog').change(function() {
//alert('Handler for .select() called.');
var tempCftID;
tempCftID = $("#selectCftDialog").val();
//alert("The tempCraftID is: CftID-" + tempCraftID)
$('#selectSpDialog option').not('#CftID-' + tempCftID).remove();
});
你可以做的是在select元素本身启动时将选项保存为data
。
$('#selectSpDialog').data('options', $('#selectSpDialog option')); // Set the jquery data `options` with the initial set of options.
$('#selectCftDialog').change(function () {
//alert('Handler for .select() called.');
var tempCftID;
tempCftID = $("#selectCftDialog").val();
//alert("The tempCraftID is: CftID-" + tempCraftID)
$('#selectSpDialog option').not('#CftID-' + tempCftID).remove(); // Ok you can remove now
});
function someEventCalledProabablyReset()
{
var select = $('#selectSpDialog');
select.html(select.data('options')); //Set back all the saved options.
}
小提琴
相关文章:
- 正在SharePoint 2013母版页中添加JQuery移动文件
- JQuery移动动态分区页面
- jquery移动对齐按钮取决于内容大小
- 在websql成功调用中Jquery移动主题打开按钮
- 通过格式化将jquery移动组件动态添加到列表视图中
- Jquery移动转换复选框在Jquery onclick函数()中第二次选中不起作用
- jQuery移动列表视图和面板
- 将代码从jquery移动到angularjs
- 无法使用谷歌地图获得多页jquery移动版
- jquery移动应用程序无法使用jquryMobile框架JS和css文件的相对路径
- 使用 jQuery(移动)更新多个选择标签
- 如何在页面之间导航后停止jquery移动中的重复数据
- 如果我在jquery移动中使用“onclick”,按钮不会改变颜色
- jQuery 移动内部页面问题
- 在 jquery 移动中离开页面时结束 SetInterval 函数
- jQuery移动显示页面5秒钟,然后重定向
- 如何正确实现Jquery移动路由器插件
- 带有scrollTop的JQuery移动错误
- Jquery移动列表视图图标未正确显示
- 动态更改jQuery移动图标的背景颜色