Reputation: 472
Sorry if this question may be simple, but I can't seem to find an answer, and it's just becoming more and more frustrating.
So, I'm on a master page and on this master page is a nifty jQuery method to 'fade' images.
Of course, the first time I load the page it blows up, but only if I'm referencing it locally.
However, I know the path to the file is correct (or if it's not it's sure fooling me) because if I enable any sort of postback (such as logging in), when the page refreshes, the jQuery loads without incident.
On the other hand, if I were to reference the library from Google, it loads fine each and every time. However, external libraries are not an option; everything in the live site has to be self contained.
Intellisense is even running perfectly fine when I'm coding in the first place.
I tried $(document).ready()
, $(window).load()
, moving it from the master page to the .aspx page. Nothing works, but only the first time.
Has anyone encountered something like this? How did you solve this conundrum?
(Also, I apologize again if this is something very simple).
Edit: It's giving an object expected error when it loads. Doing a bit of looking around it seemed to tell me that, nope, the library simply hasn't loaded yet.
Edit 2: Code:
I really should have done this before hand. My fault.
<script type="text/javascript" src="Scripts/jquery-1.6.4.js"></script>
<script type="text/javascript" >
function cycleImages() {
var $active = $('#portfolio_cycler .active');
var $next = ($('#portfolio_cycler .active').next().length > 0) ? $('#portfolio_cycler .active').next() : $('#portfolio_cycler img:first');
$next.css('z-index', 2); //move the next image up the pile
$active.fadeOut(1500, function () {//fade out the top image
$active.css('z-index', 1).show().removeClass('active'); //reset the z-index and unhide the image
$next.css('z-index', 3).addClass('active'); //make the next image the top one
});
}
//$(document).ready(function () {
// setInterval('cycleImages()', 7000);
//});
$(window).load(function () {
setInterval('cycleImages()', 7000);
});
</script>
This is the jQuery method. setInterval is the code for the fading method, but it always stops on the $(window).load
, or $(document).ready
it's placed in the topmost master page, in the header tag.
Upvotes: 0
Views: 868
Reputation: 1015
If the postback that is enabling the query reference is "logging in", then it is a permissions issue. Your application is restricting access to the .js files for only authenticated users. You need to make sure these files are accessible to anonymous users as well.
Upvotes: 1
Reputation: 1906
Can you try adding the document ready call...
<script type="text/javascript" >
$(function () {
Your code...
});
</script>
Upvotes: 0