Commit 509e5315 by Xavier Antoviaque

light-children: Re-rendering of units upon display

parent bb863a3e
......@@ -151,6 +151,16 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
super(XBlockWithLightChildren, self).__init__(*args, **kwargs)
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):
"""
......
......@@ -58,18 +58,33 @@ function MentoringBlock(runtime, element) {
}
}
$(element).find('.submit').bind('click', function() {
var data = {};
var children = getChildren(element);
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.name !== undefined) {
data[child.name] = callIfExists(child, 'submit');
function initXBlock() {
$(element).find('.submit').bind('click', function() {
var data = {};
var children = getChildren(element);
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.name !== undefined) {
data[child.name] = callIfExists(child, 'submit');
}
}
}
var handlerUrl = runtime.handlerUrl(element, 'submit');
$.post(handlerUrl, JSON.stringify(data)).success(handleSubmitResults);
});
var handlerUrl = runtime.handlerUrl(element, 'submit');
$.post(handlerUrl, JSON.stringify(data)).success(handleSubmitResults);
});
renderProgress();
}
function handleRefreshResults(results) {
$(element).html(results.html);
initXBlock();
}
function refreshXBlock() {
var handlerUrl = runtime.handlerUrl(element, 'view');
$.post(handlerUrl, '{}').success(handleRefreshResults);
}
renderProgress();
// 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