Question

I am using a lightbox called nyromodal and I am calling it manually on some thumbnail images to open a larger image.

Code:

    onclickActiveItem: function (item) {
    $('img.active').click(function(e) {
    e.preventDefault();
    $.nyroModalManual({
     url: 'image.jpg'
   });
   return false;
    });

I don't want to enter the url for each image ( as in "image.jpg") and would like a function to read the src and convert it to an href in the above code. I am thinking something like this but I am not able to find a way for it to work in the code I have.

  $('img.active').click(function(e) {
    e.preventDefault();
 var nyro = element.getAttribute('src');
 element.setAttribute('href', nyro);
    $.nyroModalManual({
     url: 'nyro'
   });
   return false;
    });

Currently it will just open the src image in a new page. I would appreciate any help ! I am a novice, so be gentle….

Mike

Was it helpful?

Solution

It seems to me like you're setting the url incorrectly and the javascript is failing.

try

    $('.nyroclickable').click(function(e) {
       $.nyroModalManual({
           url: this.src;
       });
       return false;
    });

and apply the 'nyroclickable' class to your images

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top