views:

32

answers:

2

Hi

How can i access the Instance of Boxy within its contents. I have a Link that loads a form in Boxy. Its displaying the boxy popup and its working fine. Now i want to access the instance of the boxy from form submit function. How can i do this. I have the code below.

$('a.boxy').boxy({
              modal:true,
              show:true,
              title:' ',
              closeable:true,
              center:true,
  });//boxy

link is loading the form

    <form name="subscribe" >
name <input type="text" name="name" value="' /> <br />
email <input type="text" name="email" value="' /><br />
<input type="submit" name="submit" value="subscribe" onclick="submitform()" />
</form>

<script>
function submitform()
{
   // here i want to access the boxy instance
   // also here i want to refer it and close it
}
</script>

Kind suggest

EDIT : I wanted to get the Instance of Boxy that loaded my form. I DONT want to access the link.

A: 

Hi chao!!

There is no way to get the instance of boxy container through the way you have written the code.
solution 1. You can declare a variable and create a new instance of Boxy and then refer that variable whereever you want

var boxyinstance=new Boxy.load(url,{title:"mywindow",show:true});

Now you can access it anywhere.

solution 2

if at all you want to close your boxy then you can use $('.close').click()

this will fire the click event on close button and your boxy will be closed.

i hope you have a solution;

SIA
A: 

From within your code, use Boxy.get(element) to retrieve the Boxy instance that contains your element.

For instance, give your form an ID like this:

<form name="subscribe" id="formsubscribe">

And then in your javascript, you can access the Boxy instance like this:

var myboxy = Boxy.get($('#formsubscribe'));

// Hide the box if you want to
myboxy.hide();
Spock