0

Simple Javascript No Passing ZK Parser

asked 2015-03-18 11:25:24 +0800

ansancle gravatar image ansancle
327 9

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>
delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-03-18 11:45:45 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

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

link publish delete flag offensive edit

Comments

Thanks, I knew it was something obvious, mad at myself for missing it.

ansancle ( 2015-03-18 12:03:26 +0800 )edit

+1 friend :)

chillworld ( 2015-03-18 13:00:48 +0800 )edit
0

answered 2015-03-20 07:51:46 +0800

percypeusz gravatar image percypeusz
1
http://www.inwestowaniena...

That's totally true!!

link publish delete flag offensive edit
0

answered 2015-03-19 01:16:42 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

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.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-03-18 11:25:24 +0800

Seen: 24 times

Last updated: Mar 20 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More