javascript - style binding issue when the () are not included -


can please clarify following situation knockout.js style bindings?

if use functions width(), height() bindings successful, when use properties without () bindings not successful. attr binding don`t have use ().

successful attr , style bindigs:

<div class="container" id="container" data-bind="foreach: nodes">     <div class="node" data-bind="attr:{id:id}, style: {width: width() + 'px', height: height() + 'px', left: positionleft() + 'px', top: positiontop() + 'px'}">         <span data-bind="text:name"></span>    <div class="ep"></div>     </div> 

attr bindings applied style bindings not successful

<div class="container" id="container" data-bind="foreach: nodes">     <div class="node" data-bind="attr:{id:id}, style: {width: width + 'px', height: height + 'px', left: positionleft + 'px', top: positiontop + 'px'}">         <span data-bind="text:name"></span>    <div class="ep"></div>     </div>   

if dealing observables, need call them function retrieve value, if using them in expression (like width() + 'px').

if passing observable (not type of expression), bindings smart enough unwrap observable.

so, text: myobservable fine, text: myobservable() + '!' require parens.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -