0

I have a website here.

I have this script that calls the appropriate functions for the Sticky Notes to work...

//Functionality for Sticky Notes 
    $(function() {
        $("#content").stickynote({
            size             : 'large',
            containment      : 'content',
            event            : 'dblclick',
            color            : '#de5900'                
            });


        $("#newsticky").stickynote({
            size             : 'large',
            containment      : 'content',
            color            : '#de5900'
            });
        });

It's not a repetitive piece of javascript, but I'm trying to place all these head scripts in one file. You can see that I already have a few there. You can view the file here.

When I load the file onto the index page here, the scripts are called appropriately (jquery menu and two different sliders).

When I call the same file on the Sticky Notes page, I am not able to, in addition to the jquery menu not working properly.

I'm calling the same script at the bottom of the page (before the </body> tag...

<!-- All DOM Ready Scripts -->
<script type="text/javascript" src="js/scripts.js"></script>

Not sure what I'm doing wrong.

Millhorn
  • 2,953
  • 7
  • 39
  • 77
  • 1
    Are you including jquery.js on the page where it doesn't work? I notice you're including two different versions of jquery on the http://webfro.gs/south/kb2/notes.html page, versions 1.7.1 and then 1.3.2, so that's likely causing some problems. And then on your other page you include jQuery version 1.9.1 - you might do better to figure out which version you need and stick with it everywhere. (Also, it doesn't cause a problem, but in your scripts.js you can combine the code into a single `$(document).ready(...)` handler.) – nnnnnn Aug 06 '13 at 22:10
  • 1
    P.S. Open your browser's JavaScript console (ctrl-shift-j in Chrome) and see if there are any errors reported. – nnnnnn Aug 06 '13 at 22:20
  • @nnnnnn I'm going to have to spend some time on that one. The functions of the sticky notes works with 1.3.2, but it doesn't work with 1.9.1. Do you have any thoughts on how to update my code to make it compatible with 1.9.1? – Millhorn Aug 06 '13 at 22:52

1 Answers1

0

Try taking the code block out of $(function() { }); Additionally, if the DOM is ready (i.e. if you are including the script at the bottom of the file, and all nodes are in the DOM by then) - then you don't need to place your bannerRotators in the $(document).ready(function() {});

Your code should become something like this:

$("#rotator1").bannerRotator({...});
$("#rotator2").bannerRotator({...});
$("#content").stickynote({...});
$("#newsticky").stickynote({...});
beluga
  • 826
  • 7
  • 14
  • Even if the ready handler is unnecessary (though in this case I think it is needed because the scripts are included in the head) why would it actually stop the code working? – nnnnnn Aug 06 '13 at 22:18
  • You're right, ready handler shouldn't stop the script from working. I was just trying to simplify the code. Original quesiton mentioned including the script at the bottom of the page. – beluga Aug 07 '13 at 15:42