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

  • SEARCH
  • Home
  • 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 9063247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:56:51+00:00 2026-06-16T15:56:51+00:00

It is pretty basic thing but I still can’t find the answer. I need

  • 0

It is pretty basic thing but I still can’t find the answer. I need to set View’s el: to div which is in underscore.js template.

<script id="product" type="text/template">
    <div class="productInfo"></div>
    <div class="prices"></div>
    <div class="photos"></div>
</script>

The first view renders the product template. I need to render other Views to divs in this template. I don’t know how to set el:, because el: '.prices' just don’t work with divs in template.

This Views structure is similar to How to handle initializing and rendering subviews in Backbone.js?. But I use template instead of rendering to existing divs.

  • 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-06-16T15:56:52+00:00Added an answer on June 16, 2026 at 3:56 pm

    Render the parent view, then assign the ‘.prices’ as the el of the child:

    var ParentView = Backbone.View.extend({
        render : function() {
            var html='<h1>Parent View</h1><div class="productInfo"></div><div class="prices"></div><div class="photos"></div>';
            this.$el.html(html);
    
            var prices = new PricesView({
                el : this.$('.prices')
            });
            prices.render();
        }
    });
    
    var PricesView = Backbone.View.extend({
        render : function() {
            var html='<h2>Prices View</h1>';
            this.$el.html(html);
        }
    });
    
    // Create a parent view instance and render it
    var parent = new ParentView({
        el : $('.parent')
    });
    
    parent.render();
    

    ​

    Working example on jsfiddle: http://jsfiddle.net/JpeJs/

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

Sidebar

Related Questions

I think this is a pretty basic question, but after Googling around I can't
Pretty basic question ... I can not find the compatibility table (was looking at
Pretty basic Rails question I assume but I can't figure out the simplicity of
this is a pretty basic question but I can't seem to get it right.
This seems like a pretty basic thing to do but although I've been using
Pretty basic question, but can someone please point me to a constructive tutorial on
(I think this is a pretty basic question on OOP, but unfortunately I wasn't
Pretty basic programming question, I know PHP have a function for it, but does
It's a pretty basic question on matplotlib, but I cannot figure out how to
This might be a pretty basic question, or peculiar to my set up (hopefully

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.