Ok, got another fun ExtJs question
I have a field set up to receive an image path via the MODx file browser. That sits directly below a ’placeholder’ html element:
main-img-preview.
If an image is present on load or when selected, it will be displayed in this div; if there is no image it will be empty. This works fine.
The only problem I have is when the value is cleared either by selecting ’nothing’ or deleting the path from the combobox... the image remains displayed.
Any ideas which listener I should be using to detect when the box is cleared?
var img = [];
img.push({
html: ''
,id: 'main-img-preview'
},{
xtype: 'modx-combo-browser'
,fieldLabel: 'Main Image'
,name: 'main_img'
,value: config.record.main_img
,listeners: {
'select': {fn:function(data) {
MODx.fireResourceFormChange();
var d = Ext.get('main-img-preview');
if (Ext.isEmpty(data.url)) {
d.update('');
} else {
d.update('<div id="main-image-preview"><img src="'+data.url+'"/></div>');
}
}}
}
};