[resolved] Widget preview doesn't reload when form field values are changed via javascript (5 posts)

  1. Rena Kamariotakis
    Posted 2 years ago #

    I have a widget with a file selector that utilizes the wordpress media frame. When the user selects a file, the widget's js sets the value of the text input via jQuery, but the preview isn't being triggered to reload. I noticed the reload only gets triggered if I manually edit the text input.

  2. Which theme/plugin/widget are you using?

  3. Rena Kamariotakis
    Posted 2 years ago #

    I'm not using a publicly available theme or plugin.

    I noticed the same problem is true of theme settings as well. If you try to modify a theme setting or widget setting by assigning the input value via javascript, the preview window doesn't refresh.

    You can test this by running this code:

    $('.customize-control-title').click(function() {
    	$('#customize-control-blogname input').val('Test Title');

    The above code will change the Site Title input in the theme settings when you click on the Site Title label. Notice that the preview frame doesn't reload even though the Site Title value was changed.

  4. That's an expected behavior.
    When you add a value to an input element you should always trigger a change event.

  5. Rena Kamariotakis
    Posted 2 years ago #

    Ok thanks

Topic Closed

This topic has been closed to new replies.

About this Topic