Created
March 30, 2014 09:23
-
-
Save yoga1290/9870132 to your computer and use it in GitHub Desktop.
This file contains 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 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> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script type="text/x-handlebars" data-template-name="index"> | |
{{#each}} | |
{{#link-to 'pull' id}} | |
pull#{{id}} | |
{{/link-to}} | |
<br> | |
{{/each}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="pull"> | |
data={{url}} | |
{{#link-to 'pull.url' this}} Edit {{/link-to}} | |
<br> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="pull/url"> | |
{{textarea value=url }} | |
</script> | |
</body> | |
</html> |
This file contains 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}); | |
App.Router.map(function() { | |
this.resource('pull', { path: ':postId' },function(){ | |
this.route('url'); | |
}); | |
}); | |
App.IndexRoute = Ember.Route.extend({ | |
model: function() { | |
return Ember.$.getJSON('https://api.github.com/repos/emberjs/ember.js/pulls').then(function(data) { | |
return data; | |
}); | |
} | |
}); | |
App.PullRoute= Ember.Route.extend({ | |
model:function(params){ | |
return Ember.$.getJSON('https://api.github.com/repos/emberjs/ember.js/pulls').then(function(data) { | |
for(var i=0;i<data.length;i++) | |
if(data[i].id==params.postId) | |
return data[i]; | |
return data[0]; | |
}); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment