samedi 24 janvier 2015

Populate data from model into handlebar template

I have the following rout that returns a json resoponse from the server.



myApp.VcustomersInvoiceRoute = Ember.Route.extend({
queryParams: {
order_id: {
refreshModel: true
}
},
model: function(params) {
var url = 'ajax_handler/getorderdetails/' + params.order_id;

return Ember.$.getJSON(url)
},
setupController: function(controller, model) {
this._super(controller, model);
controller.set('model', model);
}
});


Server response:



[{"id":"1929","firstname":"Aaron","lastname":"Loeb","dayphone":"650 - 346 - 8668","email":"aaronloeb@gmail.com","street":null,"city":null,"zipcode":null,"pickuptime":"02:00:00","pickupdate":"02:00:00","location":"4th Street","type":"Web order"}]


controller:



myApp.VcustomersInvoiceController = Ember.ObjectController.extend({

adding:false,
isEditing:false,
actions: {
editorederdetails: function() {
this.set('isEditing', true);

},
isadding: function() {
if (this.adding){
this.set('adding', false)
$("#add").show();
}else{
this.set('adding', true)
$("#add").hide();
};

},
},
});


what I am trying to achieve is display data from this response into the template. Something like:



<script type="text/x-handlebars" data-template-name="vcustomers/invoice">

<h1>Invoice <small># {{id}}</small></h1>
<h1>Customer <small># {{lastname}}</small></h1>




Aucun commentaire:

Enregistrer un commentaire