< Back to Templates

JavaScript Issues

Occasionally, due to how the script manipulates characters, you may find that some JavaScript you wish to use doesn't work when you put it inline in the template. To work around this, make it an external javascript. Take the opening and closing <script> tags off and save the rest of your script as yourname.js, then upload the yourname.js file to yoururl.com. Then go to Admin Panel -> Themes -> Manage Templates -> Additional Javascript Inclusions and insert <script type="text/javascript" src="http://www.yoururl.com/yourname.js"></script> somewhere between <head> and </head>, assuming it's javascript that needs to go in the header (if it's not, put it in whatever template you need it in).

Important Note For jQuery Users

WSN uses the jQuery javascript framework, along with the jQuery UI user interface framework. Both jquery and jquery UI are automatically included in every page, so you don't need to call them in if you want to use them, they're already there. Be careful that you don't call in jquery/jquery ui with a <script> tag because that would result in two copies, which can conflict and cause issues.

If the javascript files you're inserting depend on jQuery, you'll need to paste the <script ...> tags into Admin Panel -> Themes -> Manage Templates -> Additional Javascript Inclusions instead of the wrapper template, so that they get autoinserted in the right spot after all the jquery stuff is autoinserted. Likewise, any document ready function content should be placed in the Additional Document Ready Function Content template (do not include the $().ready(function() { }); part, just anything you want to add in the body of the function).

More Troubleshooting

If you're having trouble and you're sure your javascript is ok:
1) Check what libraries your javascript is using. For example, if it's using mootools or prototype you may need to insert compatibility code to make those play nice with WSN's jQuery (ideally you should migrate to jquery tools). If you're using jQuery, then remove the spots where your javascript loads jQuery and just have it use WSN's jQuery (again, your jquery-dependent javascripts will need to be called in the Additional Javascript Inclusions template).
2) There could be a function name conflict -- your file using the same function name as WSN already uses. WSN prefixes most function names to try to avoid this possibility.