Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:42:27+00:00 2026-05-25T10:42:27+00:00

I am using Backbone.js for an applciation involving a lot of different views, some

  • 0

I am using Backbone.js for an applciation involving a lot of different views, some nesting other views, and these other views could further nest other views.

Also view presentation depends on certain attributes in the model, for instance, some content is only shown if the user has been authenticated, or another type of an if-check

Coming from the world of Adobe Flex, I am used to declaring my views almost completely using markup, even deeply nested, or composite ones. Flex makes component declaration in markup a piece of cake.

I was kinda hoping that I could achieve the same kind of separation between the pure view presentation and the view logic in Backbone, but so far I’ve been struggling with that.

The reason for this is that in no way can I manage to declare a composite view using templates only. Thus, I have to resort to using BB’s render() method to instantiate subviews and append them to the parent. This is OK … but if the views get really granular, declaring them using JS is an overkill, because I literally end up appending pure HTML strings, which is a complete mess. This means that it is much better to use templating for those ones, and then just render the template instead of doing all the stuff using JS.

Using both approaches simply breaks any consistency in the application, but I push myself to be OK with it, because I’ve read a lot of (even professionally written) Backbone code, and I ‘ve seen other people struggling with the same thing.

If I cannot avoid this separation of rendering approaches, then at least I will have to put any certain boundaries of which views should be rendered with a template, and which not, or just partially. The question is what will those criteria be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:42:27+00:00Added an answer on May 25, 2026 at 10:42 am

    My methodology is to have all markup contained in templates.

    My conception of Backbone Views is that they are actually Controllers. If you consider a Controller in a more traditional web app framework, their job is to receive events, marshal models, fetch and render templates, passing in models, and to return the resulting output.

    In Backbone, the Views are the elements responsible for this task. But, instead of http being in input/output medium, the DOM is the input/output medium.

    So, I consider Views to be controllers for a specific area of UI on the screen. They listen for events, marshal models, fetch and render templates, and modify the DOM as a result.

    The decision of when to go to the trouble of generating a sub-view vs. perhaps rendering a template in a loop, is fairly loose for me.

    If it has the possibility of being used in multiple views, I’ll make a View out of it.

    If it has any events or user interactions which affect itself, but not really anything in the “parent” object I’ll make a view out of it.

    If it has any real logic, I’ll make a view out of it.

    If its a related model, or collection, I’ll make a view out of it.

    But, in any of these cases, the view does not directly generate HTML – I’ll always store the markup in a template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to test some backbone.js views using Jasmine (via jasmine-headless-webkit). Everything is working
I am building an application using the Backbone Boilerplate , and am having some
I implemented some code using backbone.js in Asp.NEt MVC3 and found backbone.js very helpful.
I've just started using backbone.js and I'm adding some basic methods to extend a
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
i'm using the kendo ui grid on my backbone application. i used this codes.
I am working on converting a Backbone application into an Ember application using Ember
I'm using Backbone and therefore Underscore to render my templates. My templates get rendered
I am using backbone and trying to create a new object and I am
I have been using Backbone.js to act as a middleman between Wordpress (using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.