2

I have been learning PHP and codeigniter for a year or so now.

However, I am intrigued at what a JS framework can do. I would prefer not to start over in Ruby, though.

I have looked around, but simply can't find enough information on how ember.js or a similar framework works with the backend.

So, assuming I have created a template:

<script type="text/x-handlebars" id="posts">
<div class='posts'>
{{#each model}}
    <h3>{{title}}</h3>
    <p> {{desc}} </p>
{{/each}}
</div>
</script>

and a model

App.Post = DS.Model.extend({
   id: DS.attr('string'),
   title: DS.attr('string'),
   desc: DS.attr('string')
});

How do I get JSON information from a URL? Assuming: http://mypage/ajax/getpostjson/postdata' will return a JSON string with id/title/desc?

The ember.js docs have something like the following:

DS.RESTAdapter.reopen({
  url: 'http://mypage/ajax/getpostjson/postdata'
});

Although I am not sure how you are supposed to call this data or where its stored, or specifically, how youre supposed to use it or set up your app.

In other tutorials, I found this:

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

Which I assume connects to App.Post. though I still am very confused.

I am just hoping to get pointed in the right direction through simple examples.

2
  • 1
    A good point to get started aside from the official ember.js docs and reading trough the source code is emberwatch.com this answer is maybe also of interest stackoverflow.com/questions/14641713/… Commented May 17, 2013 at 16:24
  • 1
    "How do I get JSON information from a URL?" - you would create an API (using whatever language, PHP, Ruby, anything...) that matches URL's that ember's data-adapter will request then use your server-side language to access the db and return your objects as JSON. Commented May 20, 2013 at 9:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.