I would like to pass a json response to handlebars. I have looked at the parse documentation and stackoverflow questions but I cannot seem to figure this out.
This is the response:
{"results":[{"address":"755 W. Yale","createdAt":"2013-02-09T01:12:15.732Z","updatedAt":"2013-02-09T01:12:15.732Z","objectId":"JomKPfme5M"}]}
This is my handlebars template:
<script id="post-template" type="text/x-handlebars-template">
<h1>{{address}}</h1>
</script>
This is the script
Parse.initialize("xxxxxx", "yyyyyy");
var listingsView = Parse.Object.extend("listings");
var query = new Parse.Query(listingsView);
query.equalTo("objectId", "JomKPfme5M");
query.first({
success: function(results){
var source = $('#post-template').html();
var template = Handlebars.compile(source);
var html = template(results);
},
error: function(object, error){
console.log(error);
}
});
Thank you
And if Hector's answer doesn't work, try this:
If you are using EmberJS Ember-Model-Parse-Adapter is good
Results is an array. Try passing the first element to the template.