javascript - How to bind style attribute top and left in rivet.js -


how bind object such i:

 var item = function() {         this.x = 10;         this.y = 10;     } var = new item(); 

to div has style "position: relative; left: {x}; top: {y}"

using http://rivetsjs.com/

you need create custom binder that:

rivets.binders['style-*'] = function(el, value){   el.style.setproperty(this.args[0], value); }; 

... ...

<p rv-style-left="item.x" rv-style-top="item.top"> 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -