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

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

$
0
0
What are you trying to do with that compute?  This kind of thing might be a bug, but is a strange use case.  You might be wanting to use the setter plugin and instead do:


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

Viewing all articles
Browse latest Browse all 3491

Trending Articles