Fix for when JS not loaded in time for TemplateRender

This commit is contained in:
Deon George 2011-04-28 17:38:14 +10:00
parent b6500224d3
commit db241f1c98

View File

@ -1667,7 +1667,25 @@ function validateForm(silence) {
foreach ($this->template->getAttributesShown() as $attribute) foreach ($this->template->getAttributesShown() as $attribute)
$this->draw('Javascript',$attribute); $this->draw('Javascript',$attribute);
echo '<script type="text/javascript">validateForm(true);</script>'."\n"; // @todo We need to sleep here a little bit, because our JS may not have loaded yet.
echo '<script type="text/javascript">
if (typeof getAttributeComponents == "undefined")
setTimeout("isJSComplete()",1000);
else
validateForm(true);
function isJSComplete() {
if (typeof getAttributeComponents == "undefined") {
alert("Our Javascript didnt load in time, you may need to reload this page");
// Sometimes the alert gives us enough time!
if (typeof getAttributeComponents != "undefined")
alert("Dont bother, our JS is loaded now!");
}
validateForm(true);
}
</script>'."\n";
printf('<!-- END: %s -->',__METHOD__); printf('<!-- END: %s -->',__METHOD__);
echo "\n"; echo "\n";
} }