Skip to main content
Added the correct solution
Source Link
obiPlabon
  • 1.7k
  • 7
  • 13

Instead ofUpdated

Actually, you have to trigger $('.deo-' + type + '-hidden-input').attr('value', attachment.url);change event to activate the Save button. WordPress widget handler listens to only changes. When you update the input field value with JS, please try DOM doesn't trigger any $( '.deo-' + type + '-hidden-input' ).val( attachment.url );change. That's why we have to trigger manually. Please check the following code -

$('.deo-' + type + '-hidden-input').val(attachment.url).trigger('change');

Instead of $('.deo-' + type + '-hidden-input').attr('value', attachment.url);, please try $( '.deo-' + type + '-hidden-input' ).val( attachment.url );

Updated

Actually, you have to trigger change event to activate the Save button. WordPress widget handler listens to only changes. When you update the input field value with JS, DOM doesn't trigger any change. That's why we have to trigger manually. Please check the following code -

$('.deo-' + type + '-hidden-input').val(attachment.url).trigger('change');
Source Link
obiPlabon
  • 1.7k
  • 7
  • 13

Instead of $('.deo-' + type + '-hidden-input').attr('value', attachment.url);, please try $( '.deo-' + type + '-hidden-input' ).val( attachment.url );