0
在我的骨幹應用中,我有一個選擇菜單,它使用路由過濾列表中的一些員工,它由部門完成。根據路線URL設置選擇的值
E.g. 本地主機/#過濾器/ HR或 本地主機/#過濾器/在我看來,會計
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);
}
},
不過,如果你訪問這些網址的直接選擇菜單中的一個不同步。
如何讓選擇與路線保持同步,其中選項選項值等於全部,人力資源和會計?