jeudi 7 mai 2015

Ember - Nothing handled the action occurs

Nothing handled the action error occurs for the following code. How to resolve this?

I have created a view, an object for my sample app using ember. But the action part is not working.

How to bind an action to a view?

HTML:

 <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Ember Starter Kit</title>
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/style.css">
  <link href="http://ift.tt/1qvC7MG" rel="stylesheet">
</head>
<body>

<script type="text/x-handlebars">
  <ul class="mod-choosable-list">    
    {{view Ember.CollectionView 
      contentBinding="App.teachersController"
      itemViewClass="App.TeacherView"
      tagName="div"
    }}
  </ul>
</script>

<script type="text/x-handlebars" data-template-name="teacher-view">
  <div {{action 'refresh'}}><b>{{view.content.name}}</b></div>
</script>




  <script src="js/libs/jquery-v1.11.1.js"></script>
  <script src="js/libs/handlebars-v1.3.0.js"></script>
  <script src="js/libs/ember-v1.6.1.js"></script>
  <script src="http://ift.tt/1tqrLlB"></script>
  <script src="http://ift.tt/1d9A66K"></script>
  <script src="js/app.js"></script>
</body>
</html>

JS:

App = Ember.Application.create({});

App.Teacher = Ember.ObjectController.extend({
    id: null, 
    name: null, 
    students: null,
    actions: {
        refresh: function(){
          alert("refresh");
        }
      }
});


App.TeacherView = Ember.View.extend({
    templateName: 'teacher-view'
});



App.set('teachersController', Ember.ArrayController.create({
    content: [
        App.Teacher.create({id:1, name: "mr.katz", students: [2, 3]}),
        App.Teacher.create({id:2, name: "mr.dale", students: [1]})
        ]
}));

Aucun commentaire:

Enregistrer un commentaire