Commit 509e5315 by Xavier Antoviaque

light-children: Re-rendering of units upon display

parent bb863a3e
...@@ -151,6 +151,16 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock): ...@@ -151,6 +151,16 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
super(XBlockWithLightChildren, self).__init__(*args, **kwargs) super(XBlockWithLightChildren, self).__init__(*args, **kwargs)
self.load_children_from_xml_content() self.load_children_from_xml_content()
@XBlock.json_handler
def view(self, data, suffix=''):
"""
Current HTML view of the XBlock, for refresh by client
"""
frag = self.student_view({})
return {
'html': frag.content,
}
class LightChild(Plugin, LightChildrenMixin): class LightChild(Plugin, LightChildrenMixin):
""" """
......
...@@ -58,6 +58,7 @@ function MentoringBlock(runtime, element) { ...@@ -58,6 +58,7 @@ function MentoringBlock(runtime, element) {
} }
} }
function initXBlock() {
$(element).find('.submit').bind('click', function() { $(element).find('.submit').bind('click', function() {
var data = {}; var data = {};
var children = getChildren(element); var children = getChildren(element);
...@@ -72,4 +73,18 @@ function MentoringBlock(runtime, element) { ...@@ -72,4 +73,18 @@ function MentoringBlock(runtime, element) {
}); });
renderProgress(); renderProgress();
}
function handleRefreshResults(results) {
$(element).html(results.html);
initXBlock();
}
function refreshXBlock() {
var handlerUrl = runtime.handlerUrl(element, 'view');
$.post(handlerUrl, '{}').success(handleRefreshResults);
}
// We need to manually refresh, XBlocks are currently loaded together with the section
refreshXBlock(element);
} }
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