Created
March 31, 2014 08:52
-
-
Save yoga1290/9888145 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> | |
<script src="http://builds.emberjs.com/ember-latest.js"></script> | |
<script src="http://builds.emberjs.com/canary/ember-data.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script type="text/x-handlebars" data-template-name="index"> | |
{{#each}} | |
{{#link-to 'post' id}} | |
post#{{id}} | |
{{/link-to}} | |
<br> | |
{{/each}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="post"> | |
{{post}} | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = Ember.Application.create({ | |
LOG_TRANSITIONS: true | |
//, | |
// LOG_TRANSITIONS_INTERNAL: true, | |
// LOG_VIEW_LOOKUPS: true, | |
// LOG_ACTIVE_GENERATION: true | |
}); | |
App.Router.map(function() { | |
this.route('post', { path: ':postId' }); | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
console.log("IndexRoute.model: store.findAll"); | |
return this.store.findAll('post'); | |
} | |
}); | |
App.Post=DS.Model.extend({ | |
postId: DS.attr('number'), | |
post:DS.attr('string') | |
}); | |
App.PostRoute= Ember.Route.extend({ | |
model:function(params){ | |
return this.store.find('post',params.postId); | |
} | |
}); | |
App.ApplicationAdapter = DS.RESTAdapter.extend({ | |
ajax: function(url,type,hash) | |
{ console.log("RESTAdapter.ajax("+url+","+type+",hash)"); | |
console.log(hash); | |
console.log(url.split('/').length); | |
if(url.split('/').length<1) | |
return {postId:1,post:'Mocking Post from RESTAdapter.ajax'}; | |
return [{postId:1,post:'Mocking Post from RESTAdapter.ajax'},{postId:2,post:'Mocking Post'}]; | |
} | |
}); | |
App.PostSerializer = DS.RESTSerializer.extend({ | |
extractArray: function(store, type, payload, id, requestType) { | |
console.log("Payload from Application-RESTAdapter to Port-RESTSerializer.extractArray:"); | |
console.log(payload); | |
return this._super(store, type, { posts: [{id:1,postId:1,post:'Mocking Post from PostSerializer'}] }, id, requestType); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment