homepage Welcome to WebmasterWorld Guest from 54.226.235.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Any idea why gallery.js not compatible w/ jQuery 1.8.2 Must use 1.4.4
ewwatson




msg:4519477
 9:33 pm on Nov 15, 2012 (gmt 0)

Any idea why my small gallery.js is not compatible with jQuery 1.8.2? I have to use jQuery version 1.4.4 for it to work. I would like to use the latest. Any obvious reasons to you js pros?

/* Gallery JS */
var gallery = function() {
var current = 1;
var total = $('#photos b').length;
$('#photos b').hide();
$('#pic1').fadeIn('slow');
$('#number').html('1 of ' + total );
setHeight(1)

$('#first').click(function(){
var prev = 1;
if (current != 1) {
$('#pic' + current).fadeOut('slow');
setHeight(prev)
$('#pic' + prev).fadeIn('slow');
current = 1;
$('#number').html(current + ' of ' + total)
}
return false;
});

$('#previous').click(function(){
var prev = current - 1;
if (prev < 1) prev = 1;
if (current != 1) {
$('#pic' + current).fadeOut('slow');
$('#pic' + prev).fadeIn('slow');
current = prev;
setHeight(current)
$('#number').html(current + ' of ' + total)
}
return false;
});

$('#next').click(function(){
var next = current + 1;
if (next > total) next = total;
if (current != total) {
$('#pic' + current).fadeOut('slow');
$('#pic' + next).fadeIn('slow');
current = next;
setHeight(current)
$('#number').html(current + ' of ' + total)
}
return false;
});

$('#last').click(function(){
var next = total;
if (current != total) {
$('#pic' + current).fadeOut('slow');
$('#pic' + next).fadeIn('slow');
current = total;
setHeight(current)
$('#number').html(current + ' of ' + total)
}
return false;
});

function setHeight(current) {}}

/* fire gallery */
$(document).ready(function(){
gallery();
});

 

ewwatson




msg:4519697
 12:41 pm on Nov 16, 2012 (gmt 0)

Wow that was hard. It works different in all three testing scenarios - local via dreamweaver - local via wamp - and online. I believe I narrowed down the problem to two scripts that are also on the page. Both need to be removed in order for the gallery.js to work with jquery 1.8.3. Smooth scroll. Replacing that with the newer version fixes half of it. But the other half - this...

document.getElementById("loading").innerHTML = "Loading...";

Loads before jquery 1.8.3 and breaks it. Or breaks the gallery.js. If I move it below jquery then it works again. But I need it to load before jquery. So, what do you think? Any obvious reason why that you know of that that one line would conflict?

FYI - all my scripts are in combined.js. It's on all the other pages. Therefore catched when the gallery is called via fancybox. Which is why I would prefer to use it verses loading a new jquery on gallery call. Thanks!

PS... I dont need this js line document.getElementById("loading").innerHTML = "Loading..."; on this page. I guess I found the pit falls of combining all your js. So if if I could disable it somehow with a little js it would be much less than another jquery to download. Can I somehow disable it on this page?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved