V
V
Vadim Belkin2014-10-02 23:10:34
JavaScript
Vadim Belkin, 2014-10-02 23:10:34

In which module should the search functionality be placed, in the router or in the view (Backbone / Requirejs)?

I'm learning Backbone and recently decided to master requirejs as well. I started with different examples. Following the advice in this post , I broke my code (more precisely, blanks) into such modules - a controller (aka a router), a model, a view.
My application has a search. I made a presentation module for search, in which, when the search form is sent, the search function actually occurs and the url changes to #search/query for example. I also added a controller (router) for searching, so that when you go to the url of the #search/query type, a search for "query" occurs.
In the next step, you need to choose whether the search function should be called in the controller or in the router. Tell me how to proceed in similar situations, whether to duplicate the function call in both modules, or in one of them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
smanioso, 2014-10-03
@smanioso

Do something to get started and keep writing. In parallel, you can think about whether you like or dislike the solution you implemented. If the nerves are in order (and we remember that maniacs will maintain our codes), then we can leave it as it is. Otherwise, remake and think again...
Well, you can find source codes / tutorials somewhere from a developer whom you personally VERY respect.
And so all you get is a mountain of advice (maybe even contradicting each other) from people you don’t know (you never know - maybe I don’t know what MVC is and I’ll start advising you?).

P
personaljs, 2014-10-16
@personaljs

The search function is better done in the controller

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question