the latest version of LightBox2 (v2.8.2) now allows a link to appear in the text under an image. This works fine usually. But my link needs to call some javascript code.
The code below for example works fine when you click on Click Here.
<a class="example-image-link"
href="http://lokeshdhakar.com/projects/lightbox2/images/image-3.jpg"
data-title="<a href='http://localhost/'>Click Here</a> ">
<img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-3.jpg" alt=""/>
</a>
For my code, I need the href within data-title to call some javascript code. These are the ones I've tried.
data-title=" <a href='javascript:submitFormFunction();' >caption </a> ">
data-title=" <a href='#' onclick='submitFormFunction();' >caption </a> ">
data-title=" <a href='#' class='submitCreateFromPreview' >caption </a> ">
None of these work, the javascript code never gets called. It appears that if the href is not a normally structured URL (http://www.google.com or http://localhost) it simply does nothing.
This is my javascript code
$(".submitCreateFromPreview").click(function(){
submitFormFunction();
});
function submitFormFunction() {
form=document.getElementById('mainform_id');
form.target='_self';
form.action='http://localhost/create.do';
form.submit();
}
I basically need all the fields in my form to be submitted when they click on the href. This code works in other places in my webapp but it does not want to work with the LightBox description href.
Any ideas what I'm doing wrong? Or anyone else have other options that perhaps I haven't tried?
Any help would be appreciated.
Thanks