Search code examples
jqueryruby-on-railsruby-on-rails-3galleria

How to retrieve the selected image ID


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.


Solution

  • 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