JS file not loading for block

Permalink
I have a custom template for the Search block which shows only the search form - for use in page head.
It is located at /blocks/search/templates/form_only/view.php
Along with that custom template is a css and js file which are names view.css and view.js respectively and are both located in the directory /blocks/search/
The css file is loading up ok but not the js file.
Have I done anything that is obviously incorrect?

 
olliephillips replied on at Permalink Reply
olliephillips
I think your view.js and view.css need to be in the form_only directory too. i.e.

/blocks/search/templates/form_only/view.js
/blocks/search/templates/form_only/view.css

Hope that helps
hardingsmith replied on at Permalink Reply
I did try that amongst various other permutations with no success. Caching was disabled so no issue there.
olliephillips replied on at Permalink Reply
olliephillips
Then I'd say your doing it right. Is it that you can not see the view.js being loaded in your source or that it is just not running. If the latter it could be a bug in the script rather than a failure to include the file.
hardingsmith replied on at Permalink Reply
Not being loaded in source.
I am running the block out of global scrapbook and calling via hardcode in my theme header template
olliephillips replied on at Permalink Reply
olliephillips
Not really sure then. I know there are some issues with scrapbook functionality - perhaps this is related?

As your search block is going to feature in your theme, why not rename your view.js put it in your theme and call that directly too? Come to think of it your view.css would probably benefit too - place the css in the main.css file of your theme. One less web request to make!

Hope that helps
hardingsmith replied on at Permalink Reply
What I ended up doing to get the thing going was exactly what you have suggested Ollie.
The CSS is now included in my main.css. Haven't had any joy getting the JS to load from my theme tho'. I tried naming it auto.js and putting in the theme root - no joy. Also have tried putting into js directory in my theme with similar result.
I am still learning the nuts and bolts of this system having used a CodeIgniter CMS extensively in a previous life.
olliephillips replied on at Permalink Reply
olliephillips
Just call your js file directly. It's not going to be autoloaded by C5 from a theme I don't think.

Then include it in your theme header
<script type="text/javascript" src="themes/yourthemename/yourjavascript.js"></script>


That should do it.

Ollie
hardingsmith replied on at Permalink Reply
I reckon you're right. That will get the thing going at the very least.
Ta Ollie.