PDA

View Full Version : Dynamic NiftyCorners



JoshuaJonah
December 3rd, 2006, 02:54 PM
I'm working on a layout for fun and i'm trying to get divs that are loaded dynamically to agree with niftycorners.

http://www.joshuajonah.com/portfolio/demo8/

If i do this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>photoblog - a Joshua Jonah design</title>
<link href="ff.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/niftycube.js"></script>
<script type="text/javascript" src="js/getimages.js"></script>

</head>
<body>
<div id="container">
<div id="header">
</div>
</div>
<div id="content">
<div id="info">
<div id="infotext">
<p>Welcome to my photo blog!</p>
<p>Follow me on a mystical photo journey through my life and time captured on camera. </p>
</div>
</div>
<script type="text/javascript">
//getimages("top");
</script>
<div id="images">
<br /><br />
<div id='box1'>
<a href='submitted/1.jpg' target='_blank'><img src='php/resizeb.php?image_name=../submitted/1.jpg&w=300&h=223' border='0'></a>
</div>
<script type='text/javascript'>
Nifty('div#box1');
</script>
</div>
</div>
</body>
</html>
It works.

But if i try it dynamically via php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>photoblog - a Joshua Jonah design</title>
<link href="ff.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/niftycube.js"></script>
<script type="text/javascript" src="js/getimages.js"></script>

</head>
<body>
<div id="container">
<div id="header">
</div>
</div>
<div id="content">
<div id="info">
<div id="infotext">
<p>Welcome to my photo blog!</p>
<p>Follow me on a mystical photo journey through my life and time captured on camera. </p>
</div>
</div>
<script type="text/javascript">
getimages("top");
</script>
<div id="images">

</div>
</div>
</body>
</html>
if (isset($_GET['action']) && $_GET['action'] == "top"){
$db=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("demo8");
$result = mysql_query('select * from images order by rating limit 1') or die("query error.");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<br /><br />
<div id='box1'>
<a href='submitted/".$row['path']."' target='_blank'><img src='php/resizeb.php?image_name=../submitted/".$row['path']."&w=300&h=223' border='0'></a>
</div><script type='text/javascript'>
Nifty('div#box1');
</script>";

}
mysql_close($db);
}This doesn't work.

If i use the "generated source" from the firefox plugin after it doesn't work, it works great.

Any ideas?

icio
December 3rd, 2006, 03:25 PM
What's the outputed source like from the PHP file?

JoshuaJonah
December 3rd, 2006, 03:28 PM
<br /><br />
<div id='box1'>
<a href='submitted/4.jpg' target='_blank'>
<img src='php/resizeb.php?image_name=../submitted/4.jpg&w=300&h=223' border='0'>
</a>
</div>
<script type='text/javascript'>
NiftyLoad=function(){
Nifty('div#box1','big');
}
</script>If i paste this in the html and can the ajax call, it works great.

icio
December 3rd, 2006, 03:35 PM
Uh, I just viewed the page and it worked fine.

JoshuaJonah
December 3rd, 2006, 04:58 PM
hmmm.

JoshuaJonah
December 3rd, 2006, 05:00 PM
oh, it's because i put that text in the page and uploaded, still same issue

JoshuaJonah
December 3rd, 2006, 05:06 PM
Tried with ids and classes, same deal.

JoshuaJonah
December 3rd, 2006, 06:06 PM
changed over to the new version of niftycorners, seems to work now, thankx for the help

JoshuaJonah
December 4th, 2006, 08:00 AM
Update: it's becasue i wasn't calling the function when it made the ajax call.

icio
December 4th, 2006, 10:30 AM
Glad I could help :shifty: