Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » How do I render a form or object into a javascript popup?

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

Page: 1 2
Go to End
Author Topic: 5356 Views
  • zalzadore
    Avatar
    Community Member
    20 Posts

    Re: How do I render a form or object into a javascript popup? Link to this post

    Ah,
    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).

  • zalzadore
    Avatar
    Community Member
    20 Posts

    Re: How do I render a form or object into a javascript popup? Link to this post

    OK,
    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('BalancePage.ss') 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?

  • lise
    Avatar
    Community Member
    47 Posts

    Re: How do I render a form or object into a javascript popup? Link to this post

    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="http://www.lisianne.com/SilverStripe/myform" 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="http://www.google.com" title="Google" rel="gb_page_center[500, 500]">Launch Google.com</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 !

    Thanks

    5356 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.