Script"
m (→Alternative) |
|||
Line 9: | Line 9: | ||
The script component is used to specify the script codes running at the browser. Notice that, unlike zscript, the script codes are running at the browser. They are usually written in JavaScript which is supported by the most of browsers. The simplest format is as follows. | The script component is used to specify the script codes running at the browser. Notice that, unlike zscript, the script codes are running at the browser. They are usually written in JavaScript which is supported by the most of browsers. The simplest format is as follows. | ||
− | == | + | ==Alternatives== |
Instead of using the script component, you could use [[ZK_ZUML_Reference/The_ZK_User_Interface_Markup_Language/Processing_Instructions/The_link,_meta_and_script_Directives|the script directive]] instead. It does not support defer, but it is more efficient since no component is created. | Instead of using the script component, you could use [[ZK_ZUML_Reference/The_ZK_User_Interface_Markup_Language/Processing_Instructions/The_link,_meta_and_script_Directives|the script directive]] instead. It does not support defer, but it is more efficient since no component is created. |
Revision as of 02:34, 15 September 2010
Script
Employment/Purpose
The script component is used to specify the script codes running at the browser. Notice that, unlike zscript, the script codes are running at the browser. They are usually written in JavaScript which is supported by the most of browsers. The simplest format is as follows.
Alternatives
Instead of using the script component, you could use the script directive instead. It does not support defer, but it is more efficient since no component is created.
Example
<syntax lang="xml" >
<zk>
<window id="win"> <button label="change color" onClick='Clients.evalJavaScript("myfunc()")' /> </window> <script type="text/javascript"> function myfunc() { jq("$win").css("backgroundColor", "blue"); }
</script>
</zk> </syntax>
Defer the evaluation
By default, the specified JavaScript code will be evaluated as soon as the page is loaded. There is an attribute called defer. By specifying true, the JavaScript code won't be evaluated until all widgets are created and bound to the DOM tree.
<syntax lang="xml"> <textbox id="inp"/> <script defer="true">
this.$f("inp").setValue("initialized");
</script> </syntax>
The defer attribute can be used with a JavaScript file as shown below. Then, the JavaScript file will be loaded after all widgets are created and bound to the DOM tree.
<syntax lang="xml"> <script src="/js/foo.js" defer="true"/> </syntax>
Supported events
None | None |
Supported Children
*NONE
Use cases
Version | Description | Example Location |
---|---|---|
5.0 | Overview and Tutorial | http://docs.zkoss.org/wiki/Client_Side_Programming |
Version History
Version | Date | Content |
---|---|---|