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.

Themes

Discuss SilverStripe Themes.

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

Fancy Box and site-search form in conflict


Reply

4 Posts   1944 Views

Avatar
Optic Blaze

22 September 2010 at 8:12am Community Member, 162 Posts

Hello. I have added fancybox to my site. As soon as i enable site-search, fancybox stops working. I am using ss2.4.1 and fancybox jquery.fancybox-1.3.1

As far as i can tell, it seems that the code for the site-search gets added to the bottom of the page, just before the body tag closes. Shouldnt this code be in the <head> tag of the page.

I am using the "//Enable search form //FulltextSearchable::enable();" command in the _config.php file to activate the site-search.

Any help will be appreciated.

Avatar
Willr

22 September 2010 at 7:28pm Forum Moderator, 5511 Posts

Look at your app for a couple of things which could be causing this.

* A lot of SilverStripe modules and core uses jQuery so to avoid including jQuery twice the best line to use to add jQuery is

<% require javascript(sapphire/thirdparty/jquery/jquery.js) %>

* Make sure your code uses closures to prevent it from conflicting. See the template for it at http://doc.silverstripe.org/javascript#custom_jquery_code.

* Ideally don't include raw script tags in templates for things which rely on other files. Best to make them a file and use <% require javascript(...) %> to add it to the requirements log.

As far as i can tell, it seems that the code for the site-search gets added to the bottom of the page, just before the body tag closes. Shouldnt this code be in the <head> tag of the page.

SS loads all its required files at the bottom of the page for performance reasons. See http://developer.yahoo.com/performance/rules.html for more information on that.

Avatar
patattrash

14 October 2010 at 6:02am Community Member, 14 Posts

Same problem here except I am using jFlow Plus for an image rotator. I have all of my js enclosed and am calling the jQuery file as you mentioned. I don't see errors in Firebug either. Any ideas?

Avatar
patattrash

14 October 2010 at 6:06am Community Member, 14 Posts

Woot woot! Idiot alert here. I had an errant ; in the closure that caused it to stop working. All's good now. Much thanks for the help.