Pergunta

I embedded the nivo slider:

<link rel="stylesheet" href="/test/workspace/css/nivo-slider.css" type="text/css" media="screen" />
<div class="slider-wrapper theme-default">
  <div class="ribbon"></div>
  <div id="slider" class="nivoSlider">
    <img src="http://amarilaw.com/test/image/2/877/317/5/0/images/lighthouse.jpg" />
    <img src="http://amarilaw.com/test/image/2/877/317/5/0/images/main-image2.png" />
  </div>
</div>

Then add the following javascript:

 <script type="text/javascript" src="/test/workspace/js/jquery.nivo.slider.js"></script>
<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
        effect: 'random', 
        pauseTime: 4000
     });
});
</script>

(jquery is already loaded in the header, so I didn't do it here)

However, I get the following error:

Uncaught TypeError: Object [object Object] has no method 'nivoSlider' /test/:76
(anonymous function) /test/:76
f.event.dispatch jquery-1.7.2.min.js:3
f.event.add.h.handle.i

There are a few other postings on this site of people getting the same error. I have tried all of the following remedies, without success:

  • making sure jquery isn't loaded twice on the page
  • changing window.load to document.ready
  • checking that all file paths to js files are correct
  • Accepting Jesus into my heart

Anyone got an idea? Here is the link, you'll have to enter the login info below to see it: [1] [1]: http://amarilaw.com/test

user: betatest

pass: pleasework

Foi útil?

Solução

You are calling your jQuery.min.js file more than once, even though you said you made sue of it.Please see lines 6 and 108. You'll notice the same file, twice.

Because of this, the function is not available to jQuery at the scope of the load, making it impossible to load the function.

Do two things here:

1

Take all those random <script> tags you have strewn all about the document and move them into the bottom of the document body.

2

Remove the jQuery.min.js file located at line #108

3

????

4

Profit.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top