Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Theme Customizer: change control text field using JavaScript WordPress

  • REFUNDED

Hello and thank you for your help,

<strong>UPDATED:</strong> Please see video with my question [[LINK href="http://youtu.be/DYI6NPufRK8"]]http://youtu.be/DYI6NPufRK8[[/LINK]]

I created custom javascript widget in Wordpress theme customizer. Result of my widget is a string that I send into textarea control 'Top bar left: Before Menu' using this code:

$('#textarea-control').val(serializedArray);


Please see attached screenshot.

<strong>Problem:</strong> Wordpress start Customizer refresh only when I put focus on textarea and then click any button.

<strong>Target:</strong> I need to fire WP Customizer refresh every time I dynamically change textarea value with JavaScript.

Answers (3)

2013-07-01

isp_charlie answers:

try this:

$('.widgets textarea').change(function(){
$('.widgets .save-button').click();
})


pavot comments:

Please see video with my question [[LINK href="http://youtu.be/DYI6NPufRK8"]]http://youtu.be/DYI6NPufRK8[[/LINK]]


pavot comments:

In the video I explain that my target is to make sure WP Customizer register/see the changes I make on textarea using JavaScript.
For now WP Customizer register the textarea change only if I manually press any key when textarea has a focus.

2013-07-01

Arnav Joy answers:

can you explain little bit more about what you want?


pavot comments:

Please see video with my question [[LINK href="http://youtu.be/DYI6NPufRK8"]]http://youtu.be/DYI6NPufRK8[[/LINK]]


pavot comments:

In the video I explain that my target is to make sure WP Customizer register/see the changes I make on textarea using JavaScript.
For now WP Customizer register the textarea change only if I manually press any key when textarea has a focus.

2013-07-01

Yakir Sitbon answers:

$( 'textarea, input', '#customize-theme-controls' ).on( 'change', function() {
$( '#customize-header-actions #save' ).trigger( 'click' );
});


pavot comments:

Please see video with my question [[LINK href="http://youtu.be/DYI6NPufRK8"]]http://youtu.be/DYI6NPufRK8[[/LINK]]


pavot comments:

In the video I explain that my target is to make sure WP Customizer register/see the changes I make on textarea using JavaScript.
For now WP Customizer register the textarea change only if I manually press any key when textarea has a focus.