How do I bind an object such as i:
var Item = function() {
this.x = 10;
this.y = 10;
}
var i = new Item();
to a div that has style "position: relative; left: {x}; top: {y}"
Using http://rivetsjs.com/
You need to create a custom binder for that:
rivets.binders['style-*'] = function(el, value){
el.style.setProperty(this.args[0], value);
};
... then ...
<p rv-style-left="item.x" rv-style-top="item.top">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With