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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:21:00+00:00 2026-06-17T19:21:00+00:00

I have an ember.js model and controller setup like so: //model App.Order = Ember.Object.extend({

  • 0

I have an ember.js model and controller setup like so:

//model
App.Order = Ember.Object.extend({

  content: null,

  create: function(data) {
    this.set('content', data);
    return this._super();
  }

});

//orders controller
App.ordersController = Ember.ArrayController.create({

  content: [],

  init: function() {

        var self = this;
    var orders = [];

    $.getJSON('js/data.json', function(data) {  
        data.forEach(function(item) { 
          var order = App.Order.create(item);
          orders.push(order);
        });
      self.set('content', orders);
    });
    },

  selectItem: function(data) {
    alert(data);
  }

});

With the following view:

{{#each App.ordersController}} 
   <div {{action selectItem target="App.ordersController"}}>{{order_number}}</div>
{{/each}}

Which prints out a list of orders with a click action that alerts the corresponding item. This works fine.

What I want to do is show a clicked item in a separate view, eventually with the goal of creating a floating dialogue with orders details shown. I’m new to ember and not sure how this should be implemented. I have a function selectItem which alert’s a clicked order but I need to link this to a separate view and print the order details.

Should I store the selected item in a separate controller with a corresponding view and update this when selectItem is clicked? Or could I update a sperate view from the ordersController? Any advice is much appreciated.

  • 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-17T19:21:01+00:00Added an answer on June 17, 2026 at 7:21 pm

    When you use the router ember does the instantiation of your class for you. By specifing the "orders" route is looks for a template called orders and a controller called OrdersController if it can’t find one it’ll generate one for you. (I’ve omitted the controller for clearity). To load your model from a json source you could have a look at ember-data.

    here is a jsfiddle so you can fiddle with it a bit.

    You should definitely have a look here these are guides for ember that really help you on the way. The documentation is getting better and better. 🙂

    JS:

    window.App = App = Em.Application.create();
    
    //model
    App.Order = Ember.Object.extend({
        order_number: null,
    });
    
    
    //we create 2 routes one for all the order and one per specific order
    App.Router.map(function(){
        this.resource('orders', { path: "/" });
        this.resource("order", { path: "/:order_id" });    
    });
    
    //the route supplies the model and handles the event to transition to a new route.    
    App.OrdersRoute = Em.Route.extend({
        events: {
            selectItem: function (orderId) {
                //select the order by the "orderId" you want as a model for your new view.
                this.transitionTo("order", order);
            }
        },
        model: function(){
            return content; //an array containing the orders;
        }
    });
    
    //supplies the model for the "order" route by selecting one acording to the params;
    App.OrderRoute = Em.Route.extend({
        model: function(params){
            return order; //select an object from the array according to the params
        },    
    });
    

    HBS:

    <script type="text/x-handlebars" data-template-name="orders">
        {{#each controller}} 
          <!-- this calls the event handler "selectItem" on the ordersroute -->
          <div {{action "selectItem" order_number}}>{{order_number}}</div>
        {{/each}}
    
        <!-- this is handled by "App.OrderRoute" -->
        <a href="#/3"/>with a direct link</a>
    </script>
    
    <script type="text/x-handlebars" data-template-name="order">
        {{content.order_number}}
        {{#linkTo "orders"}}Back to orders{{/linkTo}}
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the following ember-data model: App.Person = DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'),
var App = Ember.Application.create({ loaded:function(){ async(function(result) { data = SomeModel.create(result); App.model = data; console.log(data,
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 have an Ember.js app that has a Checklist model, where each Checklist has
I have the following StateManager: Lead.StateManager = Ember.StateManager.extend initialState: 'notParsing' notParsing: Ember.State.create startParsing: (manager,
I have a simple template that loops over a ember-data model. Inside the loop
I have an app that I would like to create. But I am not
I'm loading App.Structure objects using ember-data's fixtures adapter. These objects have embedded App.Overlay objects
I have a model that saves to my server via the ember-data rest adapter.

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.