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

Property name event not firing on computed value

$
0
0
It seems I'm not able to bind to the property name event for a computed value. Is that correct?

Say we have the following:

  1. var state = new can.Map();

  2. // primitive values
  3. state.attr('foo', 'one fish, two fish');
  4. state.attr('bar', 'red fish, blue fish');

  5. // computed value
  6. state.attr('baz', function () {
  7.     return this.attr('foo') + ", " + this.attr('bar');
  8. });

Now, if we change `foo`, the `foo` event is fired but the `baz` event is not, even though the computed value of `baz` has changed as a result of the change to `foo` ... If there's no property name event fired for computed values, how can I listen to when they change?

Here's a JSFiddle that demostrates the issue clearly: http://jsfiddle.net/45VrT/

Thanks in advance for any help you're able to provide.

-Mac


Viewing all articles
Browse latest Browse all 3491

Trending Articles