21295 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 8330 Views |
-
jQuery function not defined

16 May 2009 at 7:39am
Hi Guys
I'm having a little trouble getting this jquery to run through SS. firebug reports that:
slideSwitch is not defined
[Break on this error] setInterval( "slideSwitch()", 500 );here is the code that I have in a file jquery.slide.show.js
(function($){
function slideSwitch() {
//Some Stuff
}
$j(document).ready(function() {
setInterval( "slideSwitch()", 500 );
});
})
(jQuery);this works fine in a static HTML file, but as soon as I pass it through SS it breaks.
Anyone know what I'm doing wrong?
Cheers
-
Re: jQuery function not defined

16 May 2009 at 8:50pm
Hi aram
Are you placing this in the jQuery "scope" on purpose? You're not extending $.fn or anything...
I also wonder where that $j is coming from (see $j(document).ready in your code snippet)?I suggest you try something like this:
var $j = jQuery.noConflict();
var slideSwitch = function(){
... somestuff...
};// the following does the same as $(document).ready
$j(function(){
window.setInterval(slideSwitch, 500);
});Writing code like this has proven to work with SilverStripe (at least for me). And since you're not actually extending the jQuery functionality, there's no need to place your functions in the jQuery scope.
-
Re: jQuery function not defined

16 May 2009 at 10:25pm
Thanks banal, that did the trick!
I had misunderstood the use of the scope, I though that was needed for some reason.
Thanks again
| 8330 Views | ||
|
Page:
1
|
Go to Top |


