Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How do I render a form or object into a javascript popup?

Go to End

11 Posts   7083 Views


Community Member, 20 Posts

29 August 2009 at 10:44pm

I'll check it out, thanks.

I've ended up just putting some javascript in the template to launch a GreyBox. A bit untidy but it does the job. The template has conditional rendering to do the 'thank-you' after submission. Would still like to try figuring out how to get Ajax working through SS forms (Which I imagine I would need to launch a javascript popup).


Community Member, 20 Posts

8 September 2009 at 9:33pm

So for anyone who is interested, hello? hellllooooooooo (echo)
I've managed to do everything I needed without any Ajax in the end. I used GreyBox (didn't like the default css themes on colorbox and the GB with SS looked fine) and jQuery.

1. Render a form into a javascript popup with a thankyou message on submission.
An HTML <li> element on the main page has a javascript function 'launchSignup()' as it's 'onclick' property.
The javascript function calls GreyBox with the location of a virtual subpage of the main page
The virtual subpage function just re-renders the object with a new template file containing the form variable and different content
the form action function does its thing and re-renders the object with a thankyou template displaying more content from the CMS

2. Render HTML returned from an external service into a javascript popup
An accountID input field on the main page hold the account ID
An action button just below it has a javascript function call as its onclick property
the javascript function calls GreyBox with the URL mainpage/balance/accountID
the balance function calls the external service with the accountID and receives an HTML response which is stored in a local variable
the balance funcrion returns renderWith('') which has a reference to the local variable to render the result.

Easy once you know how :o)
All done from a single slab of PHP and a light sprinkling of javascript. Isn't SS wonderful?


Community Member, 47 Posts

19 December 2009 at 7:34am

Thanks Zalzadore. this is exactly what I am trying to do but I can't get it to work .

I have tried something as simple as :

<a href="" title="myform" rel="gb_page_center[500, 500]">Launch myform</a>
in my template

and I get a Page Not found error in the popup window.

So I tried this :
<a href="" title="Google" rel="gb_page_center[500, 500]">Launch</a>

an I get the same error in the popup window also!! I think I am missing something obvious , even though the windows pops open properly .
I am hoping you might be wathcing this great post of yours !


Go to Top