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 07-19-2011, 11:19 PM   PM User | #1
emericana
New Coder

 
Join Date: Jun 2010
Posts: 37
Thanks: 4
Thanked 0 Times in 0 Posts
emericana is an unknown quantity at this point
Jquery .load() question. CSS not showing up.

Playing around with .load() and wrote a simple script.

User clicks on a link, and then a .php page gets called from that link.

The php page which is loaded has a bunch of different css styles on it.

The classes and ID's from the loaded php page is included on the parent page...

for example if the page is index.php and I am loading test.php, all of the necessary CSS for test.php is in the <head> of index.php.


However, when the page loads, the CSS does not get shown from the loaded page.... even tho the necessary classes are there. Any ideas?

Code:
<script>
$(document).ready(function () {
$("#test1").click(function () {
			$('#bodyContainer').fadeOut('slow', function () {
	$('#loader').load('test.php');
					}); 
			});
			
			});
			</script>
Any help would be greatly appreciated. Thanks!
emericana is offline   Reply With Quote
Old 07-19-2011, 11:48 PM   PM User | #2
kberry
New Coder

 
Join Date: Jun 2011
Posts: 80
Thanks: 13
Thanked 0 Times in 0 Posts
kberry is an unknown quantity at this point
Have you tried using the function with .live() rather than .click()?

$("#test1").live('click', function () {

....

});

http://api.jquery.com/live/

Just a thought - I'm not too experienced myself.
kberry is offline   Reply With Quote
Old 07-20-2011, 12:20 AM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
No, I suspect live() won’t do anything here. It would help to actually see the entire code of the parent page where test.php is included.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 07-20-2011, 04:12 PM   PM User | #4
emericana
New Coder

 
Join Date: Jun 2010
Posts: 37
Thanks: 4
Thanked 0 Times in 0 Posts
emericana is an unknown quantity at this point
Quote:
Originally Posted by VIPStephan View Post
No, I suspect live() won’t do anything here. It would help to actually see the entire code of the parent page where test.php is included.
Yeah. Live didnt work. The test.php page is freaking huge and i need to get this file out later today so I think I will just use a less cool way of implementing the same functionality. thanks!
emericana is offline   Reply With Quote
Old 07-20-2011, 04:27 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Then provide a link to the page or post a stripped down version with the relevant parts of the code. I’m sure the solution is pretty simple.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 07-20-2011, 05:47 PM   PM User | #6
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
The classes alone are not enough if the CSS style declarations are inside the loaded content and not inside the current page. CSS style definitions will not be applied when loaded via .load() (or any Ajax technique).

Solution: Move all your CSS to the current page (the one you are calling .load() from).
devnull69 is offline   Reply With Quote
Reply

Bookmarks

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:44 PM.


Advertisement
Log in to turn off these ads.