I have a specific color saved in my database as text (for example: "#FFFFFF") and I am looking to display it similarly to the way shown in this demonstration:
This is what I currently have...
HTML:
<span class="colorpreview"> {{view App.ColorView contentBinding="primaryColor"}} random text</span>
View:
App.ColorView = Ember.View.extend({
tagName: "span",
classNameBindings: 'colorpreview',
'colorpreview': function() {
var colorFromDatabase = this.content;
$('.colorpreview').css('background-color', colorFromDatabase);
}.property('content')
});
CSS:
.colorpreview{
width: 10px ;
height: 10px ;
border-radius: 10px ;
background-color: #FFF ;
}
If more code or information is needed, feel free to ask in the comments. Thank you in advance! ;)