简体   繁体   中英

How do I create cascading/dynamic select lists with backbone

I am attempting to create a reusable backbone view that represents a select element, and supports the following:

  • Setting a selected value from a model
  • Binding other select views to it, so that when its value changes, other select views update their collections

I've seen a few different resources on this, such as

However neither of them seems to support a generalized object that fulfills both purposes - they seem to be hackish.

Does anyone have any advice on how to go about creating this? Or maybe a link to someone else's code that solves this problem elegantly?

Thanks

I would recommend you to implement event aggreator this way. http://lostechies.com/derickbailey/category/backbone-eventbinder/

so you bind the change event on your select list inside the first view to a method that triggres the update in the other views.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM