Custom Widget with IMAGE property
Dear Community,
I am trying to develop a custom widget which displays an image as a background and data in the foreground. The reason for developing a custom widget is to be able to scale the visualization to different screen sizes.
The idea is that we have Things with IMAGE properties and that we want to select a specific Thing and bind this image property to the widget, along with an infotable with data.
Once the image is bound to the widget, how can I display it in the widget? The property is defined like this:
'properties': {
'selectedImage': {
'baseType': 'IMAGE',
'isBindingTarget': true
}
The rendering is done in this way
this.renderHtml = function () {
return '<div class="widget-content widget-imagedisplay">' +
'<span class="selectedImage">' +
'</span>' +
'</div>';
};
this.afterRender = function () {
valueElem = this.jqElement.find('.selectedImage');
var myImage = this.getProperty('selectedImage');
var html = '<img src="' + myImage + '"/>';
valueElem.append(html);
};
I was expecting that this.getProperty('selectedImage') would return the image but it is difficult to verify this. And even if it returns and image, is it correct to add the html tag like I have done?
Very thankful for any help!
Erik

