根据路由URL设置select的值
Set value of select based on the route URL
在我的主干应用程序中,我有一个选择菜单,可以使用路线过滤列表中的一些员工,它可以按部门进行过滤。
例如localhost/#filter/HR或localhost/#filter/Accounting
routes: {
"filter/:type": "urlFilter"
},
urlFilter: function (type) {
this.directory.filterType = type;
this.directory.trigger("change:filterType");
},
然后在我看来:
filterByType: function () {
if (this.filterType === "all") {
this.collection.reset(contacts);
app.navigate("filter/all");
} else {
this.collection.reset(contacts, { silent: true });
var filterType = this.filterType,
filtered = _.filter(this.collection.models, function (item) {
return item.get("type").toLowerCase() === filterType;
});
this.collection.reset(filtered);
app.navigate("filter/" + filterType);
}
},
但是,如果您直接访问其中一个URL,则选择菜单将不同步。
如何使选择与路线保持同步,其中选择选项值等于"全部"、"人力资源"answers"会计"?
将onchange处理程序添加到您的列表中,并相应地更新URL(通过添加当前列表项的参数值)。防止在更改URL时重新加载页面(谷歌搜索)。确保在使用参数打开URL时(即在页面加载时)更新当前列表项。
相关文章:
- onchange值为select的重载页面
- Angularjs-设置不带ng选项的select的默认值
- 在JSP中获取嵌套形式的select列表值
- 更改select的值
- 获取 PHP 中 HTML 标记 'select' 的值
- 根据路由URL设置select的值
- 将 select 的值传递给 jQuery UI 自动完成
- 即使我按下退格键/删除键,仍保持该功能处于活动状态.以及在加载页面时获取select的值
- 如何在angularjs控制器中访问select的值
- 返回多个(multiple select)的值
- 可以'当第一个select的值改变时,让jquery设置select输入的值
- 无法从AngularJs中更新Select的值
- 查询流星集合中afQuickField select的值失败.为什么
- 如何在动态创建输入时将select的值绑定到输入
- 淘汰赛->将元素绑定到Select的值
- 如何在异步调用中使用敲除和typescript设置select的值
- jqGrid中dyanamic select的值未提交
- jqgrid:更改select的值
- 我无法在JavaScript中显示select的值
- 重置作为参数传递的select的值