This is a migrated thread and some comments may be shown as answers.
Problem in Binding Style in Template
2 Answers 71 Views
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 24 Apr 2012, 10:58 AM
I am Binding ' style ' to div which is in body
 
 
<div data-bind="style: { backgroundColor: selectedBackground }" style="height: 20px;"></div>
 
this works fine ,
 
 
But when I am define that div in template
 
 
<div class="container_1"  data-bind="style: { backgroundColor: selectedBackground }" >
....
...
..
</div>
 
it doesnt bind the div according to selectedBackground property...
 
 
Please Help Me Sir ...

2 Answers, 1 is accepted

Sort by
0
Iliana Nikolova
Telerik team
answered on 27 Apr 2012, 08:40 AM
Hi Rahul,

I tried to reproduce your scenario but everything works as expected. For convenience I attached my test project - could you please check it and let me know if I missed something?


Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Brad Sumner
Top achievements
Rank 1
answered on 22 May 2012, 10:10 PM
I think I have the same question with regards to binding a background image.  Colors are fine but the image requires more than just the path to the file, it needs to be wrapped in url().

If selectedPhoto is just the path to the file "/image/somefile.jpg" then it doesn't work.  If selectedFile is "url('/image/somefile.jpg')" then it works.  Is there a way to add in url() around the value without having to included it in the model property?

data-bind="style: { backgroundImage:  selectedPhoto  }"


Thanks,
Brad
Tags
MVVM
Asked by
Rahul
Top achievements
Rank 1
Answers by
Iliana Nikolova
Telerik team
Brad Sumner
Top achievements
Rank 1
Share this question
or