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

can.compute(initialValue, setter) doesn't work in can.Component

$
0
0
I'm trying to use can.compute seter with initial value.
Initial value is works correctly, but setter doesn't works.

I mean this construction "can.compute(initialValue, setterFn)" behaves like this "can.compute(initialValue)"

Check yourself
http://jsbin.com/OjEhIsaG/watch?js,output

  1. can.Component.extend({
  2.     tag: "my-tag",
  3.     template: "<button>click</button> {{val}}",
  4.     scope : {
  5.         val : can.compute('default val', function(newVal) {
  6.             alert('this function will never be called');
  7.             return 'I am the real value';
  8.         })
  9.     },
  10.     events : {
  11.         'button click' : function(el) {
  12.             this.scope.val(Math.random());
  13.         }
  14.     }
  15. });
  16. var template = can.view.mustache("<my-tag></my-tag>");
  17. $("body").html(template());


Viewing all articles
Browse latest Browse all 3491

Trending Articles