Jump to:

23493 Posts in 19013 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Zepto in Front End Issues

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 315 Views
  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Zepto in Front End Issues Link to this post

    I'm having trouble getting zepto.js to work in the front end on SS3.1. The Javascript console keeps throwing an End of File or Unexpected token. The standard zepto code snippet works on a plain HTML but not on the template. I'm wondering if it has something to do with tempalte processor.

    Here is the snippet for refrence:

    <script>
    document.write('<script src=' + ('__proto__' in {} ? '$ThemeDir/javascripts/zurbvendor/zepto' : '$ThemeDir/javascripts/zurbvendor/jquery') + '.js><\/script>');
    </script>

  • Guy Van Bael
    Avatar
    Community Member
    33 Posts

    Re: Zepto in Front End Issues Link to this post

    Hi,

    Judging from your code, i assume you've used the foundation framework from Zurb.
    I ran into the same problem and solved it (how strange it might sound) by getting jquery.js and zepto.js out of the vendor folder and putting it in de javascripts folder (and - of course - changing the path in the template).

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: Zepto in Front End Issues Link to this post

    That's because foundation puts those directory in a directory called vendor and the standrd htaccess file for silverstrip restricts folders named vendor. My problem is whne teh stadard call gets password through the template processor it seems to read the </script> in the document.write asn the actual close for the script

    But like I said it doesn't happen in plain html

  • kinglozzer
    Avatar
    Community Member
    142 Posts

    Re: Zepto in Front End Issues Link to this post

    Complete guess as I have no idea what's causing it, but I'd try wrapping it in CDATA tags:

    <![CDATA[
    <script>....

    </script>
    ]]>

    If that doesn't work, perhaps put the snippet in a template and do

    Requirements::customScript($this->renderWith(array('MySnippetTemplate')));

    315 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.