diff --git a/themes/survey/vanilla/options/options.js b/themes/survey/vanilla/options/options.js index f2244bcb6d1..5b2b3de9c13 100644 --- a/themes/survey/vanilla/options/options.js +++ b/themes/survey/vanilla/options/options.js @@ -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'); } }; @@ -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();