CodeIgniter Forums
Using lightbox with forms and ajax content - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using lightbox with forms and ajax content (/showthread.php?tid=32587)



Using lightbox with forms and ajax content - El Forum - 07-27-2010

[eluser]landitus[/eluser]
Hi all! I'm developing a website which uses Lightbox or modal windows heavily. In most cases there's a photo gallery inside, but there's a form in one of them. How should I override CI links to load ajax content inside the Lightbox? and how to override the form submit to make it work? I guess I should develop the whole site without js and using the controllers, that seams easy. The trick is how to add the js layer to point controllers (or load partial views).

I hope you guys get what I'm trying to accomplish. The site is similar to this: http://matthewanderson.cc/ but instead of loading each work above the page, it should open a lightbox modal window with the content.


Using lightbox with forms and ajax content - El Forum - 07-28-2010

[eluser]Zeeshan Rasool[/eluser]
If i got your question then, if you are getting images on run time using ajax call then for a form pass a param to aja call which would go to controller function, In that function you can put a check to identify that it is a form.


Using lightbox with forms and ajax content - El Forum - 07-28-2010

[eluser]landitus[/eluser]
Hey Zeeshan! Thanks for the reply. Could you be more specific? I quite not get what you mean by the check to identify part. Is there an example you can provide? Thanks!


Using lightbox with forms and ajax content - El Forum - 07-28-2010

[eluser]treeface[/eluser]
What you need to do is attach submit (click) event listeners to your forms (links), run your code to bring up the lightbox in there, and return false at the end of the function. Returning false kills the normal execution of your forms or links so that it follows through for people without javascript and performs the javascript action for people with it. This is a method that is sometimes referred to as hijax.