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

The Archive Base Latest Questions

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

I have a simple web app with a table that shows an array of

  • 0

I have a simple web app with a table that shows an array of users. The html for this is a basic table showing username / etc

The jsfiddle is here (though when you click the links to paginate jsfiddle seems to reload the page -not what I get locally when I copy/paste the below). But either way it helps show the basic app in action http://jsfiddle.net/Jmj4F/

<script type="text/x-handlebars" data-template-name="application">
  <div id="main">
    {{ outlet }}
  </div>
</script>

<script type="text/x-handlebars" data-template-name="person">
<table width="250px">                                                                            
<thead>
<th>id</th>
<th>username</th>
<th>update</th>
<th>delete</th>
</thead>
<tbody>
   {{#each person in controller}}
    <tr>
      <td>{{person.id}}</td>
      <td>{{view Ember.TextField valueBinding="person.username"}}</td>
      <td><input type="submit" value="update" {{action updatePerson person}}/></td>
      <td><input type="submit" value="delete" {{action removePerson person}}/></td>
    </tr>
   {{/each}}
</tbody>
</table>
<div id="pages">
  Page.
  <a href="/#/page/2">2</a>
  <a href="/#/page/3">3</a>
</div>
</script>

​
My app currently has 2 routes -one that pushes the default view with every user. The second is a simple page route that should slice the array and only show a subset of the users (basic pagination)

PersonApp = Ember.Application.create({});

PersonApp.ApplicationController = Ember.ObjectController.extend({});

PersonApp.ApplicationView = Ember.View.extend({
  templateName: 'application'
});

PersonApp.PersonView = Ember.View.extend({
  templateName: 'person',
  addPerson: function(event) {
    var username = event.context.username;
    if (username) {
      this.get('controller.target').send('addPerson', username);
      event.context.set('username', '');
    }
  }
});

PersonApp.Person = Ember.Object.extend({
  username: null
});

PersonApp.PersonController = Ember.ArrayController.extend({
  content: [],
  page: function(page) {
    //in a real app use the page # to slice the array
    var newContent = this.content.slice(1,2);
    this.set('content', newContent);
  }
});

PersonApp.Router = Ember.Router.create({
  root: Ember.Route.extend({
    index: Ember.Route.extend({
      route: '/',
      connectOutlets: function(router) {
        var first = PersonApp.Person.create({ username: "first" });
        var middle = PersonApp.Person.create({ username: "middle" });
        var last = PersonApp.Person.create({ username: "last" });
        var people = [first,middle,last];
        router.get('applicationController').connectOutlet('person', people);
      }
    }),
    page: Ember.Route.extend({
      route: '/page/:number',
      deserialize : function (router, params) {
        var pageNumber = params.number;
        router.get('personController').page(pageNumber);
      }
    })
  })
});

$(function () {
  PersonApp.initialize(PersonApp.Router);
});

​
Currently when I click the 2 I see the hash in the url changes from

http://localhost:8000/#/page/2

to

http://localhost:8000/#/page/undefined

This example is still very hello world so I’m open to any improvements here. I’d like to use the router based approach just because it has back button support and that’s a plus

Thank you in advance

UPDATE

I finally have a fully paginated / filter / sortable array controller (jsfiddle)

  • 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-11T09:43:56+00:00Added an answer on June 11, 2026 at 9:43 am

    Looks like I just needed to add a serialize method -now I get the page # instead of undefined

    serialize: function(router, context) {
            return {
              number: context.get('number')                                                          
            }
          }
    

    The only problem with adding this is that context is undefined so I get the following error. What should this method look like?

    Uncaught TypeError: Cannot call method ‘get’ of undefined

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

Sidebar

Related Questions

I have a simple web app with users and posts. I have an index
I'm writing a simple web app in PHP that needs to have write access
I want to create a simple web app that will have a connection from
We have a web app that among other things, allow users to leave a
I am trying to make a simple web app. I have a User table
Imagine you're writing a web app that will have 1 million users (they all
We have a web app that has a built-in search feature that our users
I have a simple web app built in asp.net webforms c# where and how
I have a simple web app: a web page with a form to submit,
So I have a simple web app where I can create a user (UserModel)

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.