An asynchoronous call in Helper is returning [object Object]
. Here is JsFiddle.
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
});
App.IndexRoute = Ember.Route.extend({
model: function() {
// for simply showing the problem, I've put the instagram id
// Actually I will parse the id from the post body
return ['fA9uwTtkSN'];
}
});
Ember.Handlebars.registerBoundHelper("format-inst", function(input){
// Add this part
if (typeof input == 'undefined'){return;}
function foo (URL) {
return $.ajax({
url: URL,
dataType: "jsonp",
}).done(function (data){
console.log(data.thumbnail_url);
return '<img src="'+data.thumbnail_url+'">';
});
}
var URL = 'http://api.instagram.com/oembed?url=http://instagr.am/p/'+input;
var r = foo(URL);
return new Ember.Handlebars.SafeString(r);
});