As shown in t" />
As shown in t" />
As shown in t"/>

Rivetjs | How to bind image link to style="background-image:url()"

185 views Asked by At

How i can bind item.image to style="background-image:url()"

<div rv-each-item="items">
   <div style="background-image:url()"></div>
</div>

As shown in this RIVETS Documentation

One-way binders

rivets.binders.color = function(el, value) {
  el.style.color = value
}

<button rv-color="label.color">Apply</button>
1

There are 1 answers

0
hyphens2 On BEST ANSWER

I fixed this issue

<div rv-each-item="items">
   <div rv-view-style="item.image"></div>
</div>

**JS**
rivets.binders['view-style'] = function(el, value) {
                el.style = 'background-image:url(https://xxx/' + value + ')';
            }