Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. App = Ember.Application.create();
  2.  
  3. var json_data = [
  4. {"color": "red"},
  5. {"color": "blue"}
  6. ];
  7.  
  8. App.Router.map(function() {
  9. this.route("index", {path: '/'});
  10. });
  11.  
  12. App.IndexRoute = Ember.Route.extend({
  13. model: function() {
  14. return json_data;
  15. }
  16. });
  17.  
  18. App.IndexController = Ember.Controller.extend({
  19. actions: {
  20. clickMe: function(event) {
  21. // How do I log the target element? This is throwing an error
  22. console.log(event.target);
  23. }
  24. }
  25. });
  26.  
  27. <script type="text/x-handlebars">
  28. <h2> Welcome to Ember.js</h2>
  29. {{outlet}}
  30. </script>
  31.  
  32. <script type="text/x-handlebars" data-template-name="index">
  33. <h2>Inside Index</h2>
  34.  
  35. <ul>
  36. {{#each model}}
  37. <li {{bind-attr class=color}} {{action 'clickMe'}}>Click here: {{color}}</li>
  38. {{/each}}
  39. </ul>
  40. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement