Skip to content

Commit

Permalink
Fixed issue #16236: Vanilla survey theme options are not saved (#1457)
Browse files Browse the repository at this point in the history
Dev: The custom options page is not properly triggering the form submit.
  • Loading branch information
gabrieljenik committed Jul 1, 2020
1 parent f16b90e commit 14a8d26
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions themes/survey/vanilla/options/options.js
Expand Up @@ -226,16 +226,21 @@ var ThemeOptions = function(){

if(generalInherit()){
$('#TemplateConfiguration_options').val('inherit');
$('#template-options-form').find('button[type=submit]').trigger('click'); // submit the form
$('#template-options-form').trigger('submit'); // submit the form
} else {
//Create a copy of the inherent optionObject
var newOptionObject = $.extend(true, {}, optionObject);
newOptionObject.generalInherit = null;

//now write the newly created object to the correspondent field as a json string
// Now write the newly created object to the correspondent field as a json string
$('#TemplateConfiguration_options').val(JSON.stringify(newOptionObject));
//and submit the form
$('#template-options-form').find('button[type=submit]').trigger('click');

// And submit the form
// Beware, we are triggering 'submit' directly, which doesn't trigger HTML5 validations.
// No HTML5 validations needed here, so all good.
// If not we would need to add a hidden submit button and trigger a 'click' on it. (see fruity theme).
// Like these: $('#template-options-form').find('button[type=submit]').trigger('click');
$('#template-options-form').trigger('submit');
}
};

Expand All @@ -244,7 +249,7 @@ var ThemeOptions = function(){
// Instance methods
var bind = function(){
//if the save button is clicked write everything into the template option field and send the form
$('.action_update_options_string_button').on('click', onSaveButtonClickAction);
$('.action_update_options_string_button, #theme-options--submit').on('click', onSaveButtonClickAction);

//Bind the hotwaps
hotSwapParentRadioButtons();
Expand Down

0 comments on commit 14a8d26

Please sign in to comment.