← Back to Upcase

Looking for advice on organizing/refactoring specific backbone view


(Yevgeniy Viktorov) #1

Hello,

with in the order management application I’m working on we’ve a ship_view which is displaying shipment options for user to choose from among with carriers. The problem is that different carriers has different set of options, some is common and some are unique, so, when user chooses a different carriers the only specific options must be displayed.

Current implementation depend on jQuery as follow:

  1. template has all possible options in a hidden layers, except carrier dropdown;
  2. view listening to the changes on the carrier dropdown;
  3. when different carrier is chosen all existent options are set to hidden state and then only specific options are displayed.

Then there is some specific carriers available which require even more options displayed at certain condition(specific carrier services, etc.), and again jQuery does all the job.

Finally there is validation method with a bunch of conditional statements.

So, how you guys would implement a such thing with backbone.js? :slight_smile:

Thanks in advance.


(Derek Prior) #2

I’m only passingly familiar with backbone, but it sounds to me like each carrier should be its own model as they have different fields and possibly different behavior (validations). The drop down would initialize the carrier model and then render the view for the selected carrier.