Commit c6fb0914 authored by Nigel McNie's avatar Nigel McNie

Fix some problems where some code was attempting to use the...

Fix some problems where some code was attempting to use the ArtefactChooserData class even when it wasn't necessary, causing errors when searching in the artefact chooser.
parent c154aff4
......@@ -148,6 +148,13 @@ function pieform_element_artefactchooser_views_js(Pieform $form, $element) {
// TODO: This is quite a lot of javascript to be sending inline, especially the ArtefactChooserData
// class.
if (!empty($element['selectone'])) {
$artefactchooserdata = '';
}
else {
$artefactchooserdata = 'new ArtefactChooserData();';
}
$pagination_js .= <<<EOF
var ul = getFirstElementByTagAndClassName('ul', 'artefactchooser-tabs', '{$form->get_name()}_{$element['name']}_container');
var doneBrowse = false;
......@@ -169,7 +176,7 @@ if (ul) {
browseA.blur();
$('artefactchooser-searchfield').value = ''; // forget the search for now, easier than making the tabs remember it
if (!browseTabCurrent) {
new ArtefactChooserData();
{$artefactchooserdata}
browseTabCurrent = true;
}
e.stop();
......@@ -185,7 +192,7 @@ if (ul) {
addElementClass(searchA.parentNode, 'current');
$('artefactchooser-searchfield').focus();
if (browseTabCurrent) {
new ArtefactChooserData();
{$artefactchooserdata}
browseTabCurrent = false;
}
e.stop();
......@@ -235,7 +242,7 @@ if (ul) {
}
}
new ArtefactChooserData();
{$artefactchooserdata}
// Update the pagination
if ($(p.id)) {
......@@ -245,12 +252,12 @@ if (ul) {
// Run the pagination js to make it live
eval(data['data']['pagination_js']);
}
// Update the result count
var results = getFirstElementByTagAndClassName('div', 'results', p.id);
if (results) {
results.innerHTML = data['data']['results'];
// Update the result count
var results = getFirstElementByTagAndClassName('div', 'results', p.id);
if (results) {
results.innerHTML = data['data']['results'];
}
}
});
});
......
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