ember.js with MySQL connection -
i trying work out small ember
application. want list items table of mysql db. able retrive , display data localstorage
of ember store
not know how can implement same thing using mysql database.
any kind of appriciated.
there few ways it, need sort of server-side api handle querying mysql database , returning data. done these days rest api using interchange format json.
whether use php, node, or server technology, there couple of ways can pull data ember. let's assume have server-side method called search, returns json array of blog posts, like:
[ {"title": "blog post 1", "body": "this blog post"}, {"title": "blog post 2", "body": "this post"} ]
the easiest way pull data ember simple ajax call:
var indexroute = ember.route.extend({ model: function() { return $.getjson("http://apiurl.com/search"); } });
in above ember route definition, model set function returns promise object returned jquery getjson method.
the template might this:
<script type="text/x-handlebars" data-template-name="index"> {{#each}} {{title}}<br/> {{description}} {{/each}} </script>
many ember users choose use emberdata instead of ajax calls, however, part of ember still under development , found had easier time building application without emberdata. check out article 1 of co-founders of discourse:
http://eviltrout.com/2013/03/23/ember-without-data.html
the ember guides pretty place start:
http://emberjs.com/guides/
http://emberjs.com/guides/routing/specifying-a-routes-model/
Comments
Post a Comment