We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33968
    • 863 Posts
    Ok, got another fun ExtJs question undecided

    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>');
                    }
                }}          
            }    
    };
    
      • 28215
      • 4,149 Posts
      Try ’change’ and look for an empty value.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 33968
        • 863 Posts
        Hi Shaun, thanks for the response.

        I’ve tried ’change’ already and no luck. I’ve tried replacing ’select’ with ’change’ in my code above just to see if it would fire at all, but can’t seem to get any response.

        Will dive deeper into the ExtJS docs...
          • 33968
          • 863 Posts
          Got ’blur’ working but not change. Weird!