TEMPLATE CONTROL: This tag allows you to register a block of client-side script with the page hosting the XMod module instance.
scriptid |
This is an identifier for your block of script that uniquely identifies it within the hosting page - across modules. It is used when registering your script block and is required in order to prevent the block from being inserted more than once in the page. This textual value can be virtually anything you want. (Required) (String Value) |
blocktype |
This attribute allows you to specify which type of script block should be emitted.
If no value is specified, the default "ClientScript" will be used. |
registeronce |
(Optional - default value is False) If this value is True, the tag will first check to see if a code block with scriptid has been registered in the page. If not, it will register your block. If it has been registered already, then no action is taken. If this value is False, then your script block will attempt to register your script block, regardless of any previously registered block. |
<xmod:scriptblock scriptid="AlertScripts" registeronce="true">
<script language="javascript">
function helloWorld(){
alert('Hello World');
}
function goodbyeWorld(){
alert('Goodbye Cruel World');
}
function showMessage(sMessage){
alert(sMessage);
}
</script>
</xmod:scriptblock>
Then, elsewhere in your template you can have:
<a href="javascript:void(0)" onclick="helloWorld();">Hello World</a><br />
<a href="javascript:void(0)" onclick="goodbyeWorld();">Goodbye</a><br />
<a href="javascript:void(0)" onclick="showMessage('<xmod:field name="MyMessage"/>')">Show Message</a>