diff --git a/common/lib/xmodule/xmodule/public/js/library_content_edit.js b/common/lib/xmodule/xmodule/public/js/library_content_edit.js index 2db019fedd..89011789b9 100644 --- a/common/lib/xmodule/xmodule/public/js/library_content_edit.js +++ b/common/lib/xmodule/xmodule/public/js/library_content_edit.js @@ -1,10 +1,11 @@ /* JavaScript for special editing operations that can be done on LibraryContentXBlock */ window.LibraryContentAuthorView = function (runtime, element) { "use strict"; - var usage_id = $(element).data('usage-id'); + var $element = $(element); + var usage_id = $element.data('usage-id'); // The "Update Now" button is not a child of 'element', as it is in the validation message area // But it is still inside this xblock's wrapper element, which we can easily find: - var $wrapper = $(element).parents('*[data-locator="'+usage_id+'"]'); + var $wrapper = $element.parents('*[data-locator="'+usage_id+'"]'); // We can't bind to the button itself because in the bok choy test environment, // it may not yet exist at this point in time... not sure why. @@ -21,12 +22,15 @@ window.LibraryContentAuthorView = function (runtime, element) { state: 'end', element: element }); - // runtime.refreshXBlock(element); - // The above does not work, because this XBlock's runtime has no reference - // to the page (XBlockContainerPage). Only the Vertical XBlock's runtime has - // a reference to the page, and we have no way of getting a reference to it. - // So instead we: - location.reload(); + if ($element.closest('.wrapper-xblock').is(':not(.level-page)')) { + // We are on a course unit page. The notify('save') should refresh this block, + // but that is only working on the container page view of this block. + // Why? On the unit page, this XBlock's runtime has no reference to the + // XBlockContainerPage - only the top-level XBlock (a vertical) runtime does. + // But unfortunately there is no way to get a reference to our parent block's + // JS 'runtime' object. So instead we must refresh the whole page: + location.reload(); + } }); }); };