how to use data-css?
Closed this issue · 2 comments
could you supply a simple example of using data-css?
I'm trying set a background-image to a url value supplied from into the template.
How do I specify the css style attribute that is to have the supplied value applied? (in this example, value is the url of the image, '/images/example.png')
<div class="bg-image" data-css="value"></div>
what i'm trying to get post processing to render in the template
<div class="bg-image" style="background-image:url(/images/example.png');">
thanks in advance
It just uses jQuery.css(value) behind the scenes, as stated in the documentation. Any of the formats accepted by the css() method of jQuery are valid. See http://api.jquery.com/css/#css2
could you supply a simple example of using data-css?
I'm trying set a background-image to a url value supplied from into the template.
How do I specify the css style attribute that is to have the supplied value applied? (in this example, value is the url of the image, '/images/example.png')<div class="bg-image" data-css="value"></div>what i'm trying to get post processing to render in the template
<div class="bg-image" style="background-image:url(/images/example.png');">thanks in advance
In your case the template should look like following
var template = {
imageValue : { 'background-image' : 'url(/images/example.png')' }
}And you can use it like this
<div class="bg-image" data-css="imageValue"></div>