How do i jump to another node, via a link, in an open lightmodal window? When the user clicks the link, I want the window's contents to be replaced with the linked node's contents.

Sorry if this has been covered before - i was unable to find a reference to it.

Comments

ah0’s picture

looking to do the same,
found any solutions to this?
cheers,

Hunabku’s picture

Well someone else claims to have solved this back in 2009 by following the suggestion given here.

However i tried following it to the T and i was unable to replace the content in a currently open modal with content from a linked url. Perhaps we have something in our configuration(other modules, etc) that is causing the parent page to go to the linked content instead of it showing up in the modal iframe.

Anyway i solved my issue with some page embedded jQuery. I designed my simple.tpl.php file with the following basic structure:

<div id="jquery-content-container">

	<!-- Content here - include links to open in this modal as follows on next line -->
	<a class="replace-content" href="/node/100?format=simple">Test Link</a>';

	<script type="text/javascript">
		$(document).ready(function() {
			$(".replace-content").click(function() {
				var linkHref = $(this).attr("href");
				function replaceContents(fullDiv) {
					//Little jquery tweak to find fullDiv's contents involves wrapping var in div first
					var wrappedDiv = "<div>"+ fullDiv +"</div>"
					var contentsDiv = $(wrappedDiv).find('div').html();
					$("#jquery-content-container").html(contentsDiv);
					return false;
				}
				$.get(linkHref, replaceContents);
				return false;
			});
		});
	</script>
	
</div>

One of the keys here is the id = "jquery-content-container" that must be assigned to the container div that encompasses all of the content in your simple.tpl.php. Another key is for all links that you want to open in the same modal to have a class = "replace-content".

Hope this helps - sure did take me awhile to figure it out.

ah0’s picture

The solution looks great, I'm going to give it a try...
Thanks aagain,
cheers,
amir