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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:15:47+00:00 2026-06-16T22:15:47+00:00

I have an API which can’t suitable for Ember-Data’s Rest Adapter. There about 3

  • 0

I have an API which can’t suitable for Ember-Data’s Rest Adapter. There about 3 models, thus I decided to use plain old $.ajax from jQuery. I blown my mind while finding a way how to retrieve models and pass them to controller in a right way.

Consider the following example from guides:

App.Router.map(function(match) {
  match('/posts').to('posts');
});

App.PostsRoute = Ember.Route.extend({
  model: function() {
    return App.Post.findAll(); // Just renamed to .findAll.
  }
});

I found that .findAll method must return an instance of E.ArrayProxy, otherwise it’s impossible to do things like this:

{{#if content}}
  ...
{{else}}
  <strong>Nothing to display</strong>
{{/if}}

And my implementation look so:

App.Post.reopenClass({
  findAll: function() {
    var result = Ember.ArrayProxy.create({content: []});

    $.getJSON('/posts', function(data) {
      $.each(data, function(i, row) {
        result.pushObject(App.Post.create(row));
      });
    });

    return result;
  }
});

I am pretty satisfied with this, but I can’t imagine how to work with single object.

App.PostsRoute = Ember.Route.extend({
  model: function(params) {
    return App.Post.find(params.post_id);
  }
});

// This will not work for me. Controller's content property will alway be null.
App.Post.reopenClass({
  find: function(postId) {
    var result = null;

    $.getJSON('/' + postId, function(data) {
      result = App.Post.create(data);
    });

    return result;
  }
});

What is the solution?

Should I return dummy Ember.ObjectProxy instance with empty content and somehow let Ember know after content actually populated with object? What is a golden path?

  • 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-16T22:15:48+00:00Added an answer on June 16, 2026 at 10:15 pm

    You can use just a plain, old object which is basically how ember-data does it.

    App.Post.reopenClass({
      find: function(postId) {
        // Set some default properties here.
        var result = Ember.Object.create({
          isLoaded: false
        });
    
        $.getJSON('/' + postId, function(data) {
          result.setProperties(data);
          result.set('isLoaded', true);
        });
    
        return result;
      }
    });
    

    Is this the golden path? Probably not, the more you dive into Ember the more you will want the rich set of features promised by ember-data. A few months back I wrote my own framework. Terrible compared to ember-data, but it didn’t require root elements, side loaded data, underscored names, and supported embedded relationships. I am hopeful that ember-data will be addressing these as it matures and I know they have been hard at work making it easier to swap out adapters and serializers.

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

Sidebar

Related Questions

I have some text. Is there is any api which can tell me the
I have a REST api which dumps some json data (user info, etc). Now
Lets say I have a Rest API which can be accessed via e.g.: mypage.com/v1/users/1234
I have an API which I'm exposing via REST and I'm deliberating about where
I have an api which takes uni code data as c character array and
I have a scenario in which I have REST API which manages a Resource
I have a REST API which accepts XML in HTTP Posts. When I send
Does Safari Reader have an API which one can use to filter the text
I have a site that has a simple API which can be used via
I have an API call which returns a double. The double's decimal length can

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.