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 8626547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:03:23+00:00 2026-06-12T08:03:23+00:00

// create Ember js app App = Ember.Application.create(); // Create a grand parent view

  • 0
// create Ember js app
App = Ember.Application.create();

// Create a grand parent view - without using templateName function/property
App.GrandparentView = Ember.View.extend({
  click: function() {
    console.log('Grandparent!');
  }
});

// Create a parent view by using templateName function/property
App.ParentView = Ember.View.extend({
  templateName:"parent-view",          
  click: function() {
    console.log('parent view!');
  }
});

// use the template to render the view content
<script type="text/x-handlebars" >
  {{#view App.GrandparentView}} 
    Click Grandparent View!     
  {{/view}}
</script>

// embed the view inside a div 
<div id="Parent">
  <script type="text/x-handlebars">
    {{view App.ParentView}}
  </script>
</div>

How does these two different approaches work in terms of view rendering in ember.js.
Which one is preferable and whats the use case or advantage of one over the other.

  • 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-12T08:03:24+00:00Added an answer on June 12, 2026 at 8:03 am

    First, do not put your Ember template <script> tags inside of a <div> tag. That will not do what you expect.

    When you use {{view App.View1}} you are telling ember to render an instance of App.View1 here. The template that it uses will be the templateName you used when building your App.View. Example:

    <script type="text/x-handlebars" data-template-name="my-template">
      Hello World!
    <script>
    
    App.View1 = Ember.View.extend({ templateName: 'my-template' });
    

    When you use {{#view App.View2}} {{/view}} you are telling ember to render an instance of App.View2 here, but defining the template inline. App.View2 will not have a templateName property, its template will be what lies inside the {{#view}}{{/view}} block. Example:

    {{#view App.View2}}
        Hello World
    {{/view}}
    
    App.View2 = Ember.View.extend();
    

    Neither is preferable, but named templates allow for reusability and make code a little cleaner. A well structured app will take advantage of both templating options. The anonymous/inline template (the App.View2 example) can be used when you want to provide different templates only once to the same view class.

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

Sidebar

Related Questions

var App = Ember.Application.create({ loaded:function(){ async(function(result) { data = SomeModel.create(result); App.model = data; console.log(data,
I have the following ember.js code: app.js: Game = Ember.Application.create({ ready: function() { Game.gameController.getChallenge();
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
So I have an object of ArrayProxy kind var App = Ember.Application.create(); App.car =
I've prepared a Fiddle to better expose the problem. http://jsfiddle.net/Xbxwr/ Code: App = Ember.Application.create();
Example in coffeescript window.APP = Ember.Application.create() APP.stuff = Ember.Object.create( name: The Name ) APP.things
Let's say I declared an application namespace: App = Ember.Application.create(); and later I write
With ember-data I'm loading all records of a model with: App.adapter = DS.Adapter.create({ findAll:
I have the following StateManager: Lead.StateManager = Ember.StateManager.extend initialState: 'notParsing' notParsing: Ember.State.create startParsing: (manager,
I just create a new repo https://github.com/tolbard/ember-moving . In this repo I extend 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.