Javascript – Close mootools Rokbox through Javascript

javascriptmootools

I am using the mootools based Rokbox plugin, on one of my sites, and I can't figure out how to close it with javascript.

I triggered the click event on the close button, but that did not work.

I found the code in the rokbox source that is used to add the click listener

this.closeButton.addEvent('click',function(e){new Event(e).stop();self.swtch=false;self.close(e)});

but since it is minified i cannot find what "this" refers to

Best Solution

The this likely refers to the rokbox instance; I don't think you need to worry about it, you're interested in the code that runs on the click event. The salient part looks to be the following:

self.swtch=false;
self.close(e);

self most likely refers to the rokbox instance, again, so assuming you instantiate it with something like

var rokbox = new RokBox(...);

you should be able to just call

rokbox.close(); 

and have it close. I haven't looked at rokbox source, so no guarantees, and not quite sure what the swtch=false does, so you probably will need to experiment a bit.