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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:52:48+00:00 2026-06-18T02:52:48+00:00

What I want to achieve: create controller with view, and in this view I

  • 0

What I want to achieve:
create controller with view, and in this view I have list of ‘Gallery’ objects. Each item has it’s own view and controller.

All files are here: https://gist.github.com/7e72bb2f532c171b1bf3

It works as intended, after hovering some text is shown/hidden, but personally I think that this it’s not so good solution.

I think that I maybe should use {{collection}} helper, but there is no documentation for it on ember.js page (there is some in code, but I’m not sure if this helper is not a little bit outdated, as in source it says “// TODO: Don’t require all of this module”).

I tried to use itemController property, but then I still have template in one file.

Also tried to use {{render}} helper in {{#each}}, but then it throw error.

So, It is there a better/cleaner way to achieve what I want?

EDIT

After making everything as in explanation provided by Michael Grassotti, I have strange behaviour – property to template is taken fron itemController, but {{action}} helper binds to parent controller. I have made screenshot to show what I’m dealing with.

enter image description here

Basically “this” in itemView points to right controller (itemController) but target property has parent controller.

After making {{action "deleteGallery" this target="this"}} and clicking it, I have error as in screenshot. At this moment, I’m running out of ideas…

EDIT2:

ok, I’m overthinking it, itemController is only for defining computed properties, not for writing {{action}} handlers.

EDIT3:
I think that my problem with itemController and event target will be fixed.
https://github.com/emberjs/ember.js/issues/1846

  • 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-18T02:52:49+00:00Added an answer on June 18, 2026 at 2:52 am

    I think that I maybe should use {{collection}} helper, but there is no documentation for it on ember.js page (there is some in code, but I’m not sure if this helper is not a little bit outdated, as in source it says “// TODO: Don’t require all of this module”).

    Agreed. Collection helper still works but I’m not certain it will be part of the public-api going forward. Best to stick with the {{#each}} helper if you can.

    I tried to use itemController property, but then I still have template in one file.

    The itemController property is a good start. that’s the best way to give each item it’s own controller.

    Also tried to use {{render}} helper in {{#each}}, but then it throw error.

    Yeah the {{render}} helper is not designed for use within an {{each}} block.

    So, It is there a better/cleaner way to achieve what I want?

    Yep. For starters use the itemController property. Then to give each it’s own view, provide an itemViewClass option to the {{each helper}}. For example:

    # in galleries_index.hbs
    {{each controller itemViewClass="App.GalleriesIndexItemView"}
    

    See the “blockless use” section of api docs for the each helper for detail.

    Then customize App.GalleriesIndexItemView to specify a template:

    App.GalleriesIndexItemView = Ember.View.extend({
        templateName: "galleries_index_item",
        tagName: 'li',
        classNames: ['span4'],
        hover: false,
        mouseEnter: function() {
            this.set('hover', true);
        },
        mouseLeave: function() {
            this.set('hover', false);
        }
    });
    

    and move html from the each helper to into the template:

    # galleries_index_item.hbs
      <div class="thumbnail">
          <a href="#">
              <img src="images/300x200.gif" alt="">
          </a>
          <div class="caption">
              <h4>{{name}}</h4>              
              {{#if view.hover}}
                  <button {{action editGallery this }} class="btn btn-mini" type="button">Edit</button>
                  <button {{action deleteGallery this}} class="btn btn-mini" type="button">Delete</button>
              {{/if}}
          </div>
      </div>
    

    Now every item has it’s own view and controller.

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

Sidebar

Related Questions

I want to achieve something like this inside a UIView: I have created a
I want to achieve something relatively simple: I want to retrieve all objects from
I want to achieve a list like this with smarty. <ul> <li> <a>img1</a> <a>img2</a>
I want to create a footer view in my table view.I have created view
I have a created a list view for one of my controller's index action.
I have a project that is a tab-bar controller. Each tab usually has a
I have Post and Comment model. I want to achieve the following: Each time
I have a main UITableView Controller that is backed by a NSFetchedResultsController, this view
I have a view controller that I want to lazily initialize, and once initialized,
I want to achieve the effect that is used on this Header on this

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.