arturadib / agility

Javascript MVC for the "write less, do more" programmer
http://agilityjs.com
MIT License
542 stars 70 forks source link

More info in model change event #104

Open deflexor opened 11 years ago

deflexor commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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

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