O
O
ODY2015-06-30 16:39:08
backbone.js
ODY, 2015-06-30 16:39:08

How to organize logic of related selectors in backbone?

there is a form with a bunch of inputs, there are associated selectors, for example, a country, a region, a city, a street, what is the best way to deal with the model + display logic, I have an assumption:
Each field is its own model with a display, for example, a country model + a collection of countries and a view that the selector renders, but here I don’t understand how to pass the selected value to the city model in order to render the cities associated with this country?
Maybe there is another, more correct solution to this situation (for example, there is one large model that stores the current state of the selected fields and can be accessed at any time)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Ostanin, 2015-07-01
@bazilio91

What is the point of creating a collection for countries and cities?
IMHO, only the form model is needed. The rest is written by hand. City\country dependencies render on model\DOM change event (Marionette.View can make life a lot easier). For each country change, re-render the form (easier)\input (a little more difficult).
And yes, there is always a ready bike:
https://github.com/powmedia/backbone-forms

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question