What I want to do, is using a submit button (or ajaxSubmitButton, or whatever) to submit a POST to a controller, but on the same button I want to bind a "colorbox" open up (yii plugin) http://www.yiiframework.com/extension/jcolorbox#hh1 .
So finally: clicking the submit button should result in a POST and in the same moment a "lightbox" / "colorbox" or however you call it should open … anyone got a nice solution for this issue? Would be awesome!
I’ve tried some things out so far, but I cant make both actions run. Always just one of them. It seems like binding the colorbox to the submit button prevents submiting the POST …
This was one tryout with an ajaxSubmitButton (didn’t do anything at all in the end):
Would be so great, if you could help me once again … I’m stuck!
Edit: Or is it maybe possible to start opening the colorbox from the controller (at the end of the action method?) … instead of a redirect or something …
Have you thought about showing the colorbox when the form has been submitted, for example:
The form is submitted via an ajax call to your controller
You set up a listener to wait for confirmation/ a callback function
If all is good, show the colorbox:
$.colorbox({href:"thankyou.html"});
I’m not sure how you would use the jcolorbox Yii extension to show the colorbox without binding it to anything, but the ColorBox website says this is possible behaviour.
this sounds like a sloution. I’m just not really sure how to set up the listener and tell the colorbox plugin to open this in a colorbox. Anyone got experience with this? Would be great … I’m a bit stuck in this point.
If I’ve written it correctly, if the form is submitted successfully, and if you have jQuery and the colorbox script being included into the page, the colorbox should show up with the URL you specify in its href property.
Thanks for your reply zaccaria! I guess i’ll give this a try … the only thing i can’t figure out, is how can I add the js code to the CActiveForm? and where?