summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TClientScript.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/WebControls/TClientScript.php')
-rw-r--r--framework/Web/UI/WebControls/TClientScript.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php
index 23aa1425..020b44b8 100644
--- a/framework/Web/UI/WebControls/TClientScript.php
+++ b/framework/Web/UI/WebControls/TClientScript.php
@@ -22,6 +22,11 @@
* <com:TClientScript UsingPradoScripts="effects, rico" />
* </code>
*
+ * The {@link setPreRenderControlTypes PreRenderControlTypes} property can
+ * be used to specify that controls type/class names that should pre-render itself
+ * even though they may not be rendered on the page. This is useful to publish
+ * controls that require assets and is only visible after a callback response.
+ *
* @TODO May be use it to include stylesheets as well.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
@@ -54,6 +59,23 @@ class TClientScript extends TControl
}
/**
+ * @param string comma delimited list of controls that wish to be prerendered
+ * so as to publish its assets.
+ */
+ public function setPreRenderControlTypes($value)
+ {
+ $this->setViewState('PreRenderControls', $value);
+ }
+
+ /**
+ * @return string comma delimited list of controls types that require prerendering.
+ */
+ public function getPreRenderControlTypes()
+ {
+ return $this->getViewState('PreRenderControls', '');
+ }
+
+ /**
* Calls the client script manager to add each of the requested client
* script libraries.
* @param mixed event parameter
@@ -69,6 +91,23 @@ class TClientScript extends TControl
if(strlen($script) > 0)
$cs->registerPradoScript($script);
}
+ $this->preRenderControls($param);
+ }
+
+ /**
+ * PreRender other controls to allow them to publish their assets. Useful
+ * when callback response components that require assets to be present on the page.
+ * @param mixed event paramater
+ */
+ protected function preRenderControls($param)
+ {
+ $types = preg_split('/,|\s+/', $this->getPreRenderControlTypes());
+ foreach($types as $type)
+ {
+ $control = Prado::createComponent($type);
+ $control->setPage($this->getPage());
+ $control->onPreRender($param);
+ }
}
}