-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have the following simple javascript and the ZK parser is barfing on the if (x < 1024)
statement and I have no idea why. It's 100% valid javascript.
Anyone know why it doesn't like this simple if statement? Driving me nuts.
Here it is from zkfiddle:
<zk>
<script type="text/javascript">
function dhHandleWindowResize()
{
var x = $(window).width();
var y = $(window).height();
if (x < 1024)
{
x = 1024;
}
}
</script>
<window border="normal" title="hello" apply="pkg$.TestComposer">
<div>Welcome to ZK Fiddle , run it right now!</div>
<button id="btn" label="Click Me To Evalute Event Binding With Composer" />
</window>
</zk>
Nothing is wrong with your if statement. The problem is that the < > characters are causing problems to the html parser so all you have to do when you write scripts (either javascript or zscript) is to enclose your code between CDATA special tags:
<script type="text/javascript"><![CDATA[ ... ]]></script>
Hope that helps
Costas
That's totally true!!
That's because the ZUL is a XML based syntax, so you cannot put an extra '<>' inside the content of each element. However, we enhanced the parser for ZHTML (a HTML syntax) in ZK 8, so the example you provided can work smoothly with ZK 8 version if the file type is in zhtml, html, or xhtml.
Asked: 2015-03-18 11:25:24 +0800
Seen: 24 times
Last updated: Mar 20 '15
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found