Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Zepto in Front End Issues


Go to End


4 Posts   854 Views

Avatar
zenmonkey

Community Member, 545 Posts

16 July 2013 at 1:43am

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>

Avatar
Guy Van Bael

Community Member, 61 Posts

18 July 2013 at 7:37pm

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).

Avatar
zenmonkey

Community Member, 545 Posts

19 July 2013 at 12:45am

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

Avatar
kinglozzer

Community Member, 187 Posts

19 July 2013 at 4:12am

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')));