Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-22-2009, 12:58 PM   PM User | #1
phoenixrip
New to the CF scene

 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
phoenixrip is an unknown quantity at this point
Why are these two conflicting?

Heya guys. I'm pretty stuck, but fairly certain there is an obvious, simple solution to this:

I have two different types of ajax call in my document, both use the same method, but each is reloading and calling a different amount of content, depending on the ID of a link that is clicked, so one link ID triggers reloading of just the content, and the other triggers reloading of the content and the navigation as well.

They both work individually, but when both are loaded into the document, on the one that is loaded last will work.

can any one help me figure out what is conflicting between the two?

Here is the first piece of code, for just the div#content being reloaded:
Code:
$j(document).ready(function() {
					   
	$j('#content').wrap('<div id="content-wrapper"></div>');
						   
	function pageload(hash) {
		if(hash.substr(hash.length-3, hash.length) == "php") {
			$j("#content-wrapper").load(hash.substr(0,hash.length-3) + ".php #content",'',function(){
				$j('#content-wrapper').slideFadeShow(1000);
				$j('#load').fadeOut('normal');												   
			});
	}
		else if(hash.substr(hash.length-3, hash.length) == "htm") {
				$j("#content-wrapper").load(hash.substr(0,hash.length-3) + ".htm #content",'',function(){
					$j('#content-wrapper').slideFadeShow(1000);
					$j('#load').fadeOut('normal');												   
				});
		}
		
		else if(hash) {
			$j("#content-wrapper").load(hash + ".html #content",'',function(){
			
				$j('#content-wrapper').slideFadeShow(1000);
				$j('#load').fadeOut('normal');												   
			});
		} 
	}
	
	$j.historyInit(pageload);			   
	
	$j('a.ajaxcontentlink').livequery('click',function(){
								  
		var hash = $j(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		
		if (hash.substr(hash.length-3, hash.length) == "php") {
			hash = hash.substr(0, hash.length-4) + "php";
		}
		else if (hash.substr(hash.length-3, hash.length) == "htm") {
			hash = hash.substr(0, hash.length-4) + "htm";
		}
		else {
			hash = hash.substr(0,hash.length-5);
		}
		$j('#content-wrapper').slideFadeHide(1000,function(){$j.historyLoad(hash)});
		$j('#load').remove();
		$j('#wrapper').append('<div id="load">LOADING<div id="loaderimage"></div></div>');
		$j('#load').fadeIn('normal');
		return false;
		
	});
	
});

Here is the second piece, which should reload everything in div#contentwithnav

Code:
$j(document).ready(function() {
					   
	$j('#contentwithnav').wrap('<div id="content-wrapper-withnav"></div>');
						   
	function pageloadwithnav(hashwithnav) {
		if(hashwithnav.substr(hashwithnav.length-3, hashwithnav.length) == "php") {
			$j("#content-wrapper-withnav").load(hashwithnav.substr(0,hashwithnav.length-3) + ".php #contentwithnav",'',function(){
				$j('#content-wrapper-withnav').slideFadeShow(1000);
				$j('#load').fadeOut('normal');												   
			});
	}
		else if(hashwithnav.substr(hashwithnav.length-3, hashwithnav.length) == "htm") {
				$j("#content-wrapper-withnav").load(hashwithnav.substr(0,hashwithnav.length-3) + ".htm #contentwithnav",'',function(){
					$j('#content-wrapper-withnav').slideFadeShow(1000);
					$j('#load').fadeOut('normal');												   
				});
		}
		
		else if(hashwithnav) {
			$j("#content-wrapper-withnav").load(hashwithnav + ".html #contentwithnav",'',function(){
				$j('#content-wrapper-withnav').slideFadeShow(1000);
				$j('#load').fadeOut('normal');												   
			});
		} 
	}
	
	$j.historyInit(pageloadwithnav);			   
	
	$j('a.ajaxandnavigationlink').livequery('click',function(){
								  
		var hashwithnav = $j(this).attr('href');
		hashwithnav = hashwithnav.replace(/^.*#/, '');
		
		if (hashwithnav.substr(hashwithnav.length-3, hashwithnav.length) == "php") {
			hashwithnav = hashwithnav.substr(0, hashwithnav.length-4) + "php";
		}
		else if (hashwithnav.substr(hashwithnav.length-3, hashwithnav.length) == "htm") {
			hashwithnav = hashwithnav.substr(0, hashwithnav.length-4) + "htm";
		}
		else {
			hashwithnav = hashwithnav.substr(0,hashwithnav.length-5);
		}
		$j('#content-wrapper-withnav').slideFadeHide(1000,function(){$j.historyLoad(hashwithnav)});
		$j('#load').remove();
		$j('#wrapper').append('<div id="load">LOADING<div id="loaderimage"></div></div>');
		$j('#load').fadeIn('normal');
		return false;
		
	});
	
});
for those wondering, there are custom effects setup like this:

Code:
jQuery.fn.slideFadeHide = function(speed, easing, callback) {
  return this.animate({opacity: 'hide', height: 'hide'}, speed, easing, callback);  
};

jQuery.fn.slideFadeShow = function(speed, easing, callback) {
  return this.animate({opacity: 'show', height: 'show'}, speed, easing, callback);  
};
Any help would be greatly appreciated, and an answer could be rewarded with a paypal donation, as this is driving me MENTAL

Cheers

Robbie
phoenixrip is offline   Reply With Quote
Old 09-22-2009, 01:05 PM   PM User | #2
seco
Regular Coder

 
seco's Avatar
 
Join Date: Nov 2008
Location: Oregon
Posts: 682
Thanks: 5
Thanked 79 Times in 77 Posts
seco has a little shameless behaviour in the past
you wouldnt happen to have this on the net somewhere where we can look at it running?
seco is offline   Reply With Quote
Old 09-22-2009, 04:12 PM   PM User | #3
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Ditto... if that's not possible can we at least see (a) your initial HTML layout and (b) the page's HTML source after the page has loaded?
__________________
Fumigator is offline   Reply With Quote
Old 09-22-2009, 08:32 PM   PM User | #4
phoenixrip
New to the CF scene

 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
phoenixrip is an unknown quantity at this point
Heya guys.

Thanks for getting back to me.

Of course... here is a live version of the broken stuff, html and both javascript callls are in the html

http://robbie-white.com/testurl/


Its a complicated problem, so I have tried to explain a little on that broken URL, but essentially, the important thing is that both versions of the code work without the other one, but when together only the second one (in this case the internal links) works, the first on called in the html is broken for some reason.
phoenixrip is offline   Reply With Quote
Reply

Bookmarks

Tags
ajax, conflict, jquery, loading

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:24 PM.


Advertisement
Log in to turn off these ads.