JSFiddle - React, Tailwind, and code Playground
JavaScript
App = Ember.Application.create();
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.ApplicationController = Ember.Controller.extend();
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
connectOutlets: function(router){
router.get('applicationController').connectOutlet('postedPosts', App.Post.find());
}
})
})
});
App.Signature = Ember.Object.extend();
App.Signature.reopenClass({
signature: '',
getSignature: function(){
$.ajax({
async: false,
url: '/auth/',
success: function(response){
this.signature = response;
}
});
return this.signature;
}
});
App.PostedPostsController = Ember.ArrayController.extend();
App.PostedPostsView = Ember.View.extend({
templateName: 'posted-posts'
});
App.Post = Ember.Object.extend();
App.Post.reopenClass({
postedPosts: [],
find: function(){
var signature = App.Signature.getSignature();
$.ajax({
url: 'http://someserver.com/1/posts/list.json?' + signature,
dataType: 'json',
success: function(response){
response.data.forEach(function(post){
this.postedPosts.addObject(App.Post.create(post))
}, this)
}
})
return this.postedPosts;
}
});
App.initialize();