I'm a jQuery newbie and have rigged Simple Modal to allow me to have more than one modal on a page by doing this in my script:
$('input.basic, a.basic').click(function (e) {
e.preventDefault();
$(this).next('.basicModalContent').modal();
});
here's my HTML:
<a class="basic linkHeading" href="#">Link Heading</a>
<div class="basicModalContent" style="display: none;">
<h1>This Resource Requires Login</h1>
<a href="#" class="simplemodal-close" title="Close">Cancel</a></p>
</div><!--basicModal-->
The issue I'm running into is everything works fine on first click & close. The second click launches the modal, but all the content is gone from inside the box.
see this link for the bug in action: http://blanksky.com/test/ebenefits21/modal.html
When you hide the dialog, jQuery changes the position of the div in the DOM, then wanting to locate it with "
$(this).next(...)
", you can not do. You should have some ID or a reference to locate otherwise.EDIT: Well, you have me thinking a little echo. I hope it is useful the code that I'm going through. I'm not tested:
I would suggest something like:
Links:
Hidden content (via CSS or inline style)
JavaScript:
Something like that should do the trick.
A solution that requires less markup is to use a single modal "window." See the following example: