Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

delegate does not catch first change

$
0
0
Hello,

I am using the can.Map.delegate plugin:

  1.   var T = can.Map.extend({

  2.   });

  3.   var t = new T();
  4.   t.bind('change', function(ev, attr, how, newVal, oldVal) {
  5.     console.log('Something on t changed', arguments);
  6.   });
  7.   t.delegate('x,y', 'change', function(ev, attr, how, newVal, oldVal) {
  8.     console.debug(attr, 'changed to', newVal);
  9.   });

  10.   t.attr('x', 10); // doesn't display "x changed to"
  11.   t.attr('y', 20); // displays "y changed to 20"
  12.   t.attr('x', 30); // displays "x changed to 30"
The problem is on line 14, where the message should be "x changed to 10", but it doesn't show. The second change of the attribute 'x' on line 16 does show the message that x changed to 30.


Viewing all articles
Browse latest Browse all 3491

Trending Articles