views:

842

answers:

2

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

+1  A: 

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.

Aeon
A: 

For the current rokbox and mootools 1.12, the command is

window.parent.rokbox.close(null)

it took forever to come up with this. By the way, this is to close the rokbox from the page that's loaded in the rokbox, by clicking a regular button instead of the 'x' for instance. Also, to add to what Aeon wrote, the rokbox is automatically created so it's unnecessary to instantiate it.