Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone.js - Routers, view rendering and general conceptualizations
    primarykey
    data
    text
    <p>I've done a fair bit of introductory tutorial reading (including Absolute Beginners, <a href="http://javascriptissexy.com/learn-backbone-js-completely/" rel="noreferrer">Learn it Completely</a>, and large parts of the 2 Code School Backbone courses) and I can completely see the potential that Backbone offers. But the comprehension light bulb hasn't quite turned on yet...I think the vast majority of examples being simple todo apps makes it seem a lot more trivial than it actually is when working on more complex projects.</p> <p>My experiments have gone ok to a point - but I think getting answers or feedback about the following series of scattershot questions now might save me a lot of frustration and move me up the learning curve towards where I'd like to be. I've tried to include relevant snippets for examples that are of a detailed nature. </p> <p>1) <strong>Routers are awesome, but are / are not the place for any heavy lifting?</strong></p> <p>The following router works to move user from initial page load into a specific route (search) which has its SearchBoxView instantiated in the last js loaded similar to app.js in the TodoMVC example. However trying to setup the views in router as shown for SummaryResultsView generates an 'is not a constructor' error.</p> <pre><code>var Workspace = Backbone.Router.extend({ routes: { '': 'default', 'search': 'searchBox', 'summary': 'summary', 'detail': 'detail', }, default: function() { console.log("Router: Default"); track.Router.navigate("#search", { trigger: true, replace: true }); }, searchBox: function () { console.log("Router: Search"); }, summary: function () { console.log("Router: Summary"); new track.SummaryResultsView({ el: $("#summary #results")}); }, </code></pre> <p>I <em>JUST</em> found <a href="https://github.com/thomasdavis/backbonetutorials/blob/gh-pages/examples/modular-backbone/js/router.js" rel="noreferrer">https://github.com/thomasdavis/backbonetutorials/blob/gh-pages/examples/modular-backbone/js/router.js</a> which seems to have the router initialize behaving in a similar fashion to what I'd expect. Will try that approach next.</p> <p>2) <strong>Do you have to a main page view that builds a lot of state logic in render?</strong></p> <p>What I was aiming for with the router above is that each route will have a number of views that show / hide or change their presentation based on results in the collection. Setting up what views to render on state change seemed like a good place. The TodoMVC example has the app.js view render function does a lot of the equivalent logic.</p> <p>3) <strong>Underscore Templates in external files w/o require.js</strong></p> <p>I'm pretty sure I'll get to including require.js eventually - but to simplify part of the learning curve wanted to start without it. Also b/c the templates will be pulling field titles from a separate CMS and not (yet) sure how nice it will play with AMD. </p> <p>4) <strong>Can it help reduce plugin dependencies like colorbox and datatables?</strong></p> <p>One of the proof of concept items I'm working towards with Backbone is a smedium-sized app that has a fair amount of presentation code written explicitly to work with these jQuery plugins. It isn't bad persay, but it seems like writing similar functionality in backbone structure would be a bit more maintainable or at least legible to understand what it is doing. Mind you, I found backbone tablesorter (out of links for post) in my travels and can't (yet) tell if it would result in any more or less tightly coupled code w.r.t plugin.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload