Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More info in model change event #104

Open
deflexor opened this issue May 16, 2013 · 4 comments
Open

More info in model change event #104

deflexor opened this issue May 16, 2013 · 4 comments

Comments

@deflexor
Copy link

Here is code illustrating the issue:
http://jsfiddle.net/fLjeC/4/

If you change any of fields, you will see that change event callback function is called with
only single parameter, which is event. Why not add at least one extra parameter containing new value ?

@robertjustjones
Copy link
Collaborator

deflexor, I've updated your code here: http://jsfiddle.net/pbkFL/1/ showing how to access those values:

Here's the key change that pulls the data from the model.

  'change': function(e,someone1,someone2) {
      var someone1 = this.model.get( 'a' ),
          someone2 = this.model.get( 'b' );
      console.log( "a or b changed e: %o, someone1: %o, someone2: %o", e, someone1, someone2 );

@deflexor
Copy link
Author

Thank you for reply, but here is the updated snippet:
http://jsfiddle.net/fLjeC/5/

And here how can we determine which children fired an event ?

@phonovision
Copy link

And here how can we determine which children fired an event ?

Yes, a solution to this would be very nice. Sometimes you need some sort of a "catch all" change-handler that depends on the actual changed element.

Why not add at least one extra parameter containing new value ?

This seems the most obvious way to me. I guess it also could be appended to the event-parameter (to keep the agility syntax consistent).

@alexchandel
Copy link

The event object / event handler parameters should contain at least:

  • the sender (the Agility MVC object, not the DOM object)
  • the model parameter that has changed
  • possibly the former value

BTW, this should exist for every Event, not just the Agility events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants