diff --git a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/sliders.js b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/sliders.js index 8005c97180..a12f0099c6 100644 --- a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/sliders.js +++ b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/sliders.js @@ -18,8 +18,9 @@ define('Sliders', ['logme'], function (logme) { if (sliderDiv.length === 1) { onEvent = 'slide'; if (sliderDiv.attr('data-on_event') === 'change') { - onEvent = 'change'; + onEvent = 'slidechange'; } + createSlider(sliderDiv, paramName, onEvent); } else if (sliderDiv.length > 1) { logme('ERROR: Found more than one slider for the parameter "' + paramName + '".'); @@ -48,9 +49,7 @@ define('Sliders', ['logme'], function (logme) { 'min': paramObj.min, 'max': paramObj.max, 'value': paramObj.value, - 'step': paramObj.step, - - onEvent: sliderOnSlide + 'step': paramObj.step }); // Tell the parameter object stored in state that we have a slider @@ -58,6 +57,9 @@ define('Sliders', ['logme'], function (logme) { // will also update the value of this slider. paramObj.sliderDiv = sliderDiv; + // Atach a callback to update the slider's parameter. + paramObj.sliderDiv.on(onEvent, sliderOnSlide); + return; // Update the 'state' - i.e. set the value of the parameter this @@ -66,7 +68,6 @@ define('Sliders', ['logme'], function (logme) { // This will cause the plot to be redrawn each time after the user // drags the slider handle and releases it. function sliderOnSlide(event, ui) { - // Last parameter passed to setParameterValue() will be 'true' // so that the function knows we are a slider, and it can // change the our value back in the case when the new value is diff --git a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/state.js b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/state.js index c1cfcd1b04..e5cd8634bc 100644 --- a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/state.js +++ b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/state.js @@ -241,7 +241,7 @@ define('State', ['logme'], function (logme) { } // Update the single slider with the new parameter's value. - if (parameters[paramName].sliderDiv !== null) { + if ((slider === false) && (parameters[paramName].sliderDiv !== null)) { parameters[paramName].sliderDiv.slider('value', paramValueNum); }