Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I'm needing to dynamically create a prettyPhoto (modal window) link...

Posted on 2010-08-25
2
Medium Priority
?
1,194 Views
Last Modified: 2012-05-10
Hello,

I have a select menu and based off the selection I'm dynamically creating a link on the page for the PrettyPhoto modal window to appear but it doesn't seem to be working. I placed a static link on the page and it works fine. I believe it's because the page loads and the pretty photo script can't recognize dynamically created links.

Brian
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="../js/jquery-1.4.2.js"></script>

<script>
	function addPublication() {
		$("option", "select[name='magazine']").click(function() {
			if( $(this).is(":selected")) {
				 $('#myURL').html("<a href='edit_issues.cfm?magazine_id="+ $(this).val() +"&iframe=true&amp;width=700&amp;height=500' rel='prettyPhoto[iframe]'>Edit/Add Issues</a>");
			}
			else {
				$('#myURL').remove();
			}
		});
	};
</script>
</head>

<body>
			<cfinvoke 
				component = "cfc.magazines" 
				returnvariable="qMagazines"
				method="getMagazines">
				</cfinvoke> 
				
				<select name="magazine" onClick="addPublication();">
					<option value="">Please Choose A Magazine</option>
					<cfoutput query="qMagazines">
					<option value="#record_id#">#magazine_name#</option>
					</cfoutput>
				</select><br /> 

		<div class="gallery clearfix">
			static link that works > <a href="edit_issues.cfm?magazine_id=1&iframe=true&amp;width=700&amp;height=500" rel="prettyPhoto[iframe]">Edit/Add Issues</a><br />
			
			dynamic link that is created just fine and exactly like the link above but when clicked doesn't pull up the PrettyPhoto (Modal) window<div id="myURL"></div>
		</div>
		
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
	$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
});
</script>
</body>
</html>

Open in new window

0
Comment
Question by:brihol44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
wuff earned 2000 total points
ID: 33525197
You could put this in your Javascript function right after creating the dynamic link

      $("#myURL a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});

0
 

Author Comment

by:brihol44
ID: 33525845
That works if I make the right selection the first time. If I close the modal window and try selecting another selection from the menu it does the same thing before. I'm playing around with it right now but if you know why it wouldn't work after making another selection then please let me know. I'm obviously a beginner here at JQuery.

Thanks,

Brian
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question