Question

Here's a link to a jsfiddle: http://jsfiddle.net/Qt972/

When you run the fiddle you'll see a name and a button to make the "person" say hello. This works fine, however the "event" is undefined.

An even simpeler case also fails:

http://jsfiddle.net/CCg2K/1/

Does anyone know how I can fix this issue?

Était-ce utile?

La solution

When you do a console.log(arguments) inside your action callback you can see that there are actually 3 parameters passed. The first one is the view, the second is the event and the third is the context.

You can rewrite your edit action like this:

edit: function(view, event, context) {
  var target = event.target;
  ...
}

UPDATE: since commit 657a2664 - available in release 0.9.6 I guess - only a single event parameter is passed which has the view and context as properties. So if you want to access those you have to do the following:

edit: function(event) {
  var view = event.view;
  var context = event.context;
  ...
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top