1

I have a problem. I want to be able to instanciate more than one Seadragon Viewer objects on the same page. All is fine, except that I have written event handler (like click, mousemouse, etc) and I want them to be generic.

However, it seems that there is no way to know on what Seadragon viewer the event is called. For example, all the jQuery events can call the "this" to refer to the element on which the event was trigger. The only way I found so far is to declare my Seadragon viewers as Global Variables, which is not super elegant...

Is there a "this" equivalent for the Seadragon Events?

Alexandre
  • 507
  • 1
  • 5
  • 16

1 Answers1

0

I got an slightly more elegant solution using an array for all the Seadragon Viewer objects I declare. So, I store a reference of the SD Viewer in a global array. Each of the elements that is used to intanciate a Seadragon object have the class "Seadragon".

When the event is fired, I do:

var id = $(this).closest('.SeadragonViewport').attr('id'); var cSDObj = g_SDObjects[id];

where cSDObj is the current Seadragon object I should use.

I am opened to any suggestions that is better than this one, but so far, it workd!

Alexandre
  • 507
  • 1
  • 5
  • 16