Including jquery syntax code

ssuh's Avatar


06 Aug, 2010 03:54 PM

how do i include jquery syntax code?

i keep getting an error that's it's not well formatted?

<script type ="text/javascript">
        $('#featured-event-in').after('<div id="navCycle">').cycle({ 
            fx:      'scrollLeft', 
            speed:    300, 
            timeout:  3500,
            pause: 1, 
            next: '#next2', 
            pager: '#navCycle'
  1. Support Staff 1 Posted by Tim on 06 Aug, 2010 05:24 PM

    Tim's Avatar

    Hi Steve,

    It is likely complaining because it sees <div id="navCycle"> with no closing </div> tag. Try wrapping your code in passthrough code sections.

    Let me know if that helps!

  2. 2 Posted by ssuh on 06 Aug, 2010 05:33 PM

    ssuh's Avatar

    using version - 6.7 - r14254

    I tried the passcode using a text and xhtml block. it's outputted with the start-code and end-code in the html view.

    <!--#START-CODE <script type ="text/javascript"> $("document").ready(function(){ $('#featured-event-in').after('<div id="navCycle">').cycle({ fx: 'scrollLeft', speed: 300, timeout: 3500, pause: 1, next: '#next2', pager: '#navCycle' }); }) </script> #END-CODE-->
  3. 3 Posted by Penny on 06 Aug, 2010 06:12 PM

    Penny's Avatar

    Generally, I would wrap the contents of that script inside CDATA tags within your actual script tags if I were putting it in a page.

    Alternatively, you could save the content of that script as a Javascript file and the link to the file.

    As a developer who likes scripts separated from html, I would do the second. But the first method works for me.

  4. 4 Posted by ssuh on 06 Aug, 2010 07:40 PM

    ssuh's Avatar

    Why is the start-code not being processed though?

  5. 5 Posted by Penny on 06 Aug, 2010 09:23 PM

    Penny's Avatar

    I did not have this issue and I just tested it with your code in my instance of 6.7. I just put the START-CODE and END-CODE tags around the script. It looks like in the sample above your end p tag and beginning to the h1 tag got wrapped into your pass through code. I am not sure if this is an issue with code displaying properly in this site.

    Also worth-noting, if you are going to use pass through code, that script will not execute in Cascade but it will on your published site.

    I hope this helps.

  6. 6 Posted by ryan.griffith on 09 Aug, 2010 01:14 PM

    ryan.griffith's Avatar

    Alternatively, what we do is add a text field to our pages, dump the JS snippet into the field, and then spit it out into a region within our template. This will allow you to use your JS within Cascade.

    There is a drawback; however. It seems as though sometimes conditionals are rewritten with HTML entities, causing the JS to error. For example, the most common occurrence is with < and >, you'll get see their entity representation.

    To get around this, we have an additional file asset include so that we can simply include a JS file, rather than throw the code in the text field. We use some XSLT to add the script tag into a template region. This will also let you see the JS working within Cascade.

  7. 7 Posted by ssuh on 09 Aug, 2010 03:05 PM

    ssuh's Avatar

    What version of the cms are u running?

    using version - 6.7 - r14254

  8. 8 Posted by ryan.griffith on 09 Aug, 2010 03:11 PM

    ryan.griffith's Avatar

    We're on v6.4.6, but that method should work just fine for v6.7. Not sure about the entities problem, though, since we're not able to test with that version yet.

  9. 9 Posted by johnsons4 on 11 Aug, 2010 05:24 PM

    johnsons4's Avatar

    we usually use external js files for jquery scripts like this and refer to them in a block placed in a head tag or end of body region. If it's simple or short jquery, I can usually paste it in the HTML box of an XHTML block without a problem.

    This was working in both 6.4.6 and our current 6.7.1

  10. 10 Posted by ssuh on 12 Aug, 2010 06:27 PM

    ssuh's Avatar

    Well it turns out i was not closing my - end-code correctly.

    thanks for all your help!

  11. Tim closed this discussion on 12 Aug, 2010 06:36 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM