Make simple databinding with rivetsjs

61 Views Asked by At

can someone help me making

<div id="infoview">
          Infos <span data-text="appel:ref"></span>
</div>

The javascript:

var appel = {
    adresse: "Plateau Rue du Commerce",
    ref: "helo"
};
rivets.bind($('#infoview'), {appel: appel});

I used the last minified version of rivets.js Thanks, here the jsfiddle

1

There are 1 best solutions below

0
On

There what i done, for any people having same issue (i don't think there will be)

<div id="infoview">
          Infos <span rv-text="appel.ref"></span>
</div>

And javacsript:

var appel = {
    adresse: "Plateau Rue du Commerce",
    ref: "helo"
};
rivets.bind($('#infoview'), {appel: appel});

Mixed data-text and rv-text, so the proper way is rv-text. And beware of keypath appel.ref and appel:ref, if you want to use appel:ref you need to create an adaptater