agility
agility copied to clipboard
More info in model change event
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, 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 );
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 ?
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).
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.