Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用backbone.js 创建即时搜索。我打算在一个视图中保留搜索框。其他视图中的全部内容。如果用户在搜索视图中键入任何内容,则另一个视图中的集合会自动更新。我不想要代码,但如果方法是对是错或者最好的方法是什么,我需要一些评论。
在初始化时,您可以让搜索框和搜索结果视图都引用同一个集合。在搜索字段的键位/更改时,您调用集合上的方法(或触发事件)以更新搜索词并调用 fetch。然后,您将搜索结果视图设置为在集合的更改事件上自动重新呈现。