Commit 904007a9 by Braden MacDonald Committed by E. Kolpakov

Fix: don't need to reload the whole page to refresh_children from the container view

parent e498872a
/* 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();
}
});
});
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment