From e3e0c974eebb79f16ebede84718c37c0abda8680 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Fri, 10 May 2019 13:28:50 +0800 Subject: [PATCH] MDL-65560 qtype_multichoice: prevent form change dialog --- question/type/multichoice/amd/build/clearchoice.min.js | 2 +- question/type/multichoice/amd/src/clearchoice.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/question/type/multichoice/amd/build/clearchoice.min.js b/question/type/multichoice/amd/build/clearchoice.min.js index 3a002441f49..16837effdd5 100644 --- a/question/type/multichoice/amd/build/clearchoice.min.js +++ b/question/type/multichoice/amd/build/clearchoice.min.js @@ -1 +1 @@ -define(["jquery","core/custom_interaction_events"],function(a,b){var c={CHOICE_ELEMENT:".answer input",CLEAR_CHOICE_ELEMENT:'div[class="qtype_multichoice_clearchoice"]'},d=function(a){a.find('input[type="radio"]').prop("checked",!0)},e=function(a,b){return a.find('div[id="'+b+'"]')},f=function(a){a.addClass("sr-only")},g=function(a){a.removeClass("sr-only")},h=function(a,h){var i=e(a,h);a.on(b.events.activate,c.CLEAR_CHOICE_ELEMENT,function(){d(i),f(i)}),a.on(b.events.activate,c.CHOICE_ELEMENT,function(){g(i)})},i=function(b,c){b=a("#"+b),h(b,c)};return{init:i}}); \ No newline at end of file +define(["jquery","core/custom_interaction_events"],function(a,b){var c={CHOICE_ELEMENT:".answer input",CLEAR_CHOICE_ELEMENT:'div[class="qtype_multichoice_clearchoice"]'},d=function(a){a.find('input[type="radio"]').prop("checked",!0)},e=function(a,b){return a.find('div[id="'+b+'"]')},f=function(a){a.addClass("sr-only")},g=function(a){a.removeClass("sr-only")},h=function(a,h){var i=e(a,h);a.on(b.events.activate,c.CLEAR_CHOICE_ELEMENT,function(a,b){d(i),f(i),b.originalEvent.preventDefault()}),a.on(b.events.activate,c.CHOICE_ELEMENT,function(){g(i)})},i=function(b,c){b=a("#"+b),h(b,c)};return{init:i}}); \ No newline at end of file diff --git a/question/type/multichoice/amd/src/clearchoice.js b/question/type/multichoice/amd/src/clearchoice.js index 3c15efb7e34..5ca09ce44c2 100644 --- a/question/type/multichoice/amd/src/clearchoice.js +++ b/question/type/multichoice/amd/src/clearchoice.js @@ -75,11 +75,14 @@ define(['jquery', 'core/custom_interaction_events'], function($, CustomEvents) { var registerEventListeners = function(root, fieldPrefix) { var clearChoiceContainer = getClearChoiceElement(root, fieldPrefix); - root.on(CustomEvents.events.activate, SELECTORS.CLEAR_CHOICE_ELEMENT, function() { + root.on(CustomEvents.events.activate, SELECTORS.CLEAR_CHOICE_ELEMENT, function(e, data) { + // Mark the clear choice radio element as checked. checkClearChoiceRadio(clearChoiceContainer); // Now that the hidden radio has been checked, hide the clear choice option. hideClearChoiceOption(clearChoiceContainer); + + data.originalEvent.preventDefault(); }); root.on(CustomEvents.events.activate, SELECTORS.CHOICE_ELEMENT, function() {