Bootstrap Dynamic Modal View With AJAX |
03-13-2016, 02:00 PM
(This post was last modified: 03-13-2016, 02:03 PM by PaulD. Edit Reason: Quick typo )
Hi,
It is actually very easy. In your main view you have a single modal window view, something like: Code: <!-- Modal --> Your controller calls your view like normal, but include some javascript that, on click, loads the modal with a loader message, then opens the modal window, ajax's to get the real content (or error message), and then loads the modal content with that information. Something like Code: <script> This is not necessarily working code, nor a full working example. The examples here are just simplified example bits from sites I have doing the same thing. My controller also loads the modal with the CSRF token for CSRF validation too. I also usually include some JS that updates the loader message should the ajax call fail. But as I said, have chopped this down for simplicity and added comments to help. One modal window - fired from a single class - content loaded through Ajax call to get content. Once you get the hang of it, it is not only powerful, it really brings modal windows to life. I find myself using them more and more now, for all sorts of things. Hope that helps. Paul. |
Messages In This Thread |
Bootstrap Dynamic Modal View With AJAX - by pb.sajjad - 03-07-2016, 07:25 AM
RE: Bootstrap Dynamic Modal View With AJAX - by keulu - 03-07-2016, 09:12 AM
RE: Bootstrap Dynamic Modal View With AJAX - by ivantcholakov - 03-13-2016, 07:58 AM
RE: Bootstrap Dynamic Modal View With AJAX - by PaulD - 03-13-2016, 02:00 PM
RE: Bootstrap Dynamic Modal View With AJAX - by pb.sajjad - 03-15-2016, 01:12 AM
RE: Bootstrap Dynamic Modal View With AJAX - by PaulD - 03-15-2016, 08:53 AM
RE: Bootstrap Dynamic Modal View With AJAX - by next468 - 11-29-2016, 05:22 AM
|