agility icon indicating copy to clipboard operation
agility copied to clipboard

More info in model change event

Open deflexor opened this issue 11 years ago • 4 comments

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 ?

deflexor avatar May 16 '13 15:05 deflexor

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 );

robertjustjones avatar May 16 '13 15:05 robertjustjones

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 ?

deflexor avatar May 16 '13 18:05 deflexor

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).

phonovision avatar Jun 11 '13 13:06 phonovision

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.

alexchandel avatar Jul 14 '13 14:07 alexchandel