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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:11:43+00:00 2026-06-12T22:11:43+00:00

Code for view is Ember.View.extend({ template: Ember.Handlebars.compile(html), // html is in string content: function()

  • 0

Code for view is

Ember.View.extend({
        template: Ember.Handlebars.compile(html), // html is in string
        content: function() {
            return [
            { Title: "Dashboard", ID: "dashboard" },
            { Title: "Invoices", ID: "invoices" },
            { Title: "Expenses", ID: "expenses" },
            { Title: "People", ID: "people" },
            { Title: "Reports", ID: "reports" },
            { Title: "Settings", ID: "settings" }
        ]},
        iconClass: function(link){
          return "icon icon-" + link.ID
        }
    });

Template (show above as “html”) looks like this:

<ul>
    {{#each link in view.content}}
    <li>
        <a>
            <span class="icon" {{bindAttr class="view.iconClass(link)"}}></span>
            <span class="title">{{link.Title}}</span>
        </a>
    </li>
    {{/each}}
</ul>

This renders

<span class="icon" data-bindattr-2="2"></span>

So additional class attribute is not rendered. Am I doing something wrong with scope or?

NOTE:

I changed my code to show what I want to do.

  • 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-12T22:11:44+00:00Added an answer on June 12, 2026 at 10:11 pm

    EDIT

    According to the new question, you’ll have to use an Ember.CollectionView:

    App.FooCollectionView = Ember.CollectionView.extend({
        itemViewClass: Ember.View.extend({
            iconClass: function() {
                 return "icon-dashboard icon " + this.get('content.ID');
            }.property('content.ID')
        })
    });
    

    As you can see, each itemViewClass has a property iconClass which depends on its content.id.

    Now you’ll have to add the collection view in the template of the view FooView:

    <ul>
        {{#collection App.FooCollectionView contentBinding="view.content"}}
        <li>
            <a>
                <span {{bindAttr class="view.iconClass"}}>foo</span>
                <span class="title">{{view.content.Title}}</span>
            </a>
        </li>
        {{/collection}}
    </ul>
    

    Here we are using the {{collection}} Handlebars helper, and we bind the content of the FooView to the FooCollectionView.

    It will automatically create an itemViewClass instance for each object in the CollectionView.content, set the its to the associated object, and add it to the view.

    I suggest you to read the Ember.CollectionView documentation.

    And you could try this solution in this JSFiddle.

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

Sidebar

Related Questions

I want to implement the following Javascript code in Coffeescript App.ItemView = Ember.View.extend({ classNameBindings:
HTML header `<script type=text/x-handlebars data-template-name=application> {{view App.NavbarView}} {{outlet}} </script>` footer JS `App.ApplicationController = Em.Controller.extend();
Why does the fullName function in this code execute twice? Person = Ember.Object.extend({ //
I have this code for view: App.TodoView = Em.View.extend({ labelView: Em.TextField.extend({ }), createNew:function ()
Given that I have this code: Ember.App.View = Ember.View.extend({ templateName: templateA }); Ember.App.View =
if we have a c# code between view page and wants to print string
I have the following ember.js code: app.js: Game = Ember.Application.create({ ready: function() { Game.gameController.getChallenge();
I have simple view in my Ember.js application, like this. Each content element consists
I have the following html and js code snippets. Basically, I'm trying out Ember's
In the aspx code view , we can code like this: <asp:ListBox runat=server> <asp:ListItem

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.