diff options
Diffstat (limited to 'framework')
3 files changed, 52 insertions, 3 deletions
diff --git a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js index 23b49f56..740f9607 100644 --- a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js +++ b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js @@ -414,6 +414,28 @@ Prado.Element = },
/**
+ * Appends a javascript block to the document.
+ * @function ?
+ * @param {string} boundary - Boundary containing the javascript code
+ */
+ appendScriptBlock : function(boundary)
+ {
+ var content = Prado.Element.extractContent(this.transport.responseText, boundary);
+ if(content == null)
+ return;
+ var id = 'inline_' + boundary;
+
+ if($(id))
+ document.body.removeChild($(id));
+
+ var el = document.createElement("script");
+ el.type = "text/javascript";
+ el.id = id;
+ el.text = content;
+ document.body.appendChild(el);
+ },
+
+ /**
* Extract content from a text by its boundary id.
* Boundaries have this form:
* <pre>
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 453824db..ecc213f5 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -434,6 +434,26 @@ class TCallbackClientScript extends TApplicationComponent }
/**
+ * Appends a block of inline javascript enclosed in a boundary.
+ * Similar to to evaluateScript(), but functions declared in the
+ * inline block will be available to page elements.
+ * @param THtmlWriter writer for the content.
+ */
+ public function appendScriptBlock($content)
+ {
+ if($content instanceof TControl)
+ {
+ $boundary = $this->getRenderedContentBoundary($content);
+ }
+ else if($content instanceof THtmlWriter)
+ {
+ $boundary = $this->getResponseContentBoundary($content);
+ }
+
+ $this->callClientFunction('Prado.Element.appendScriptBlock', array($boundary));
+ }
+
+ /**
* Renders the control and return the content boundary from
* TCallbackResponseWriter. This method should only be used by framework
* component developers. The render() method is defered to be called in the
diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php index 325105bc..4736df0e 100644 --- a/framework/Web/UI/WebControls/TClientScript.php +++ b/framework/Web/UI/WebControls/TClientScript.php @@ -132,9 +132,16 @@ class TClientScript extends TControl {
if($this->getHasControls())
{
- $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
- $this->renderChildren($writer);
- $writer->write("\n/*]]>*/\n</script>\n");
+ if($this->getPage()->getIsCallback())
+ {
+ $extWriter= $this->getPage()->getResponse()->createHtmlWriter();
+ $this->renderChildren($extWriter);
+ $this->getPage()->getCallbackClient()->appendScriptBlock($extWriter);
+ } else {
+ $writer->write("<script type=\"text/javascript\">\n/*<![CDATA[*/\n");
+ $this->renderChildren($writer);
+ $writer->write("\n/*]]>*/\n</script>\n");
+ }
}
}
}
|