0

I'm using galleria plugin in my rails 3 application. I need to retrieve the img ID from the selected image in order to update my database. I tried use the method .getActiveImage, but I really don't know how to implement it.

Please let me know if you have any ideas on how to make this code work or if you have another solution to recommend.

Thank you.

Zeck
  • 6,433
  • 21
  • 71
  • 111

3 Answers3

1

You can listen to the image event and pick up the original IMG element in the galleriaData property from the event object:

Galleria.on('image', function(e) {
    alert( e.galleriaData.original.id );
});

http://galleria.io/docs/api/events/#image

David Hellsing
  • 106,495
  • 44
  • 176
  • 212
0

Easy

$(function() {  // <-- on dom ready
    $('img').click(function() {  // <-- bind click event to all images
        alert(this.id); // <-- alert current clicked image id
        // or this $(this).prop('id');  this using jquery object
    });
});​
wirey00
  • 33,517
  • 7
  • 54
  • 65
0

I suggest to give all the images of your plugin same classname, so when image from your plugin is selected this will give you id of image from plugin .

<img class="agree" id="imageid" src="http://i158.photobucket.com/albums/t116/kaloesche68/Olympics.jpg" width="256" height="256"/>​

$(document).ready(function() {
  $("img.agree").click(function(){
       alert($(this).attr("id"));
       return false;
    });

});
Sibu
  • 4,609
  • 2
  • 26
  • 38