Commit d6b909de authored by Nigel McNie's avatar Nigel McNie
Browse files

(#3016) Evaluate legend javascript when fieldsets are loaded by ajax.

parent b6b4d44c
......@@ -83,4 +83,32 @@ function pieform_element_fieldset(Pieform $form, $element) {/*{{{*/
return $result;
}/*}}}*/
/**
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* javascript. This feature is used in the views interface.
*
* In theory, this could go upstream to pieforms itself
*
* @param Pieform $form The form
* @param array $element The element
*/
function pieform_element_fieldset_views_js(Pieform $form, $element) {
// NOTE: $element['name'] is not set properly at this point
$element = pieform_element_artefactchooser_set_attributes($element);
$blockname = json_encode('blockinstance_' . substr($form->get_name(), 3));
return <<<EOF
forEach(getElementsByTagAndClassName('legend', null, $blockname), function(legend) {
if (legend.firstChild.tagName == 'SCRIPT') {
if (typeof(legend.firstChild.text) != 'undefined') {
// IE7
eval(legend.firstChild.text);
}
else {
eval(legend.firstChild.firstChild.nodeValue);
}
}
});
EOF;
}
?>
Supports Markdown
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