![]() |
Can't close bootstrap modal called from a controller - 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: Can't close bootstrap modal called from a controller (/showthread.php?tid=57471) |
Can't close bootstrap modal called from a controller - El Forum - 03-17-2013 [eluser]Cgull[/eluser] Hello, I have a problem with bootstrap and codeigniter. Hope someone can help. I have a view called homepage with a link in it: Code: <a href="<?php echo site_url('page/backissues/thinklocal/') . '/' . $province->id; ?>">View Back Issues</a> This view is calling this controller function: Code: public function backissues() The _modal_layout view looks like this: Code: <?php $this->load->view('components/page_head'); ?> The backissues view: Code: <div class="modal-header"> When I click the close button on the modal, the modal closes but it does not go back to the homepage view, I just see a grey screen. If I remove the modal.hide() script, nothing happens when I click the close button. So how can I close the modal window? Thank you. Can't close bootstrap modal called from a controller - El Forum - 03-17-2013 [eluser]TheFuzzy0ne[/eluser] Your HTML isn't valid, so that might be a good place to start. http://validator.w3.org Can't close bootstrap modal called from a controller - El Forum - 03-17-2013 [eluser]Cgull[/eluser] Checked my file: Line 14, Column 56: Bad value X-UA-Compatible for attribute http-equiv on element meta. <meta http-equiv="X-UA-Compatible" c /> ✉ Error Line 34, Column 121: An img element must have an alt attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. …calhost/thinklocal/uploads/issues/freestate/thinklocal/img/dec2012.jpg" /></td> Don't think that should stop the modal from closing? Also, now it is closing but I don't go back to the screen that calls it, I just get a grey screen. Can't close bootstrap modal called from a controller - El Forum - 03-17-2013 [eluser]davidMC1982[/eluser] It doesn't go back to your homepage because you redirected away from it when the user clicked this link on your homepage: Code: <a href="<?php echo site_url('page/backissues/thinklocal/') . '/' . $province->id; ?>">View Back Issues</a> So now you've gone to a page "backissues" that contains nothing more than the modal. When the modal is closed (which really just does something like display:none in css), you are rightfully shown what amounts to an empty html document. I guess what you're trying to do is have a modal popup on your homepage that displays the backissues? To do this you'll want to make your backissues function return the html for the modal body content: Code: echo $this->load->view('_modal_layout', $this->data, TRUE); And your link on your homepage will be something like this: Code: <a data-toggle="modal" data-target="#modal" href="<?php echo site_url('page/backissues/thinklocal/' . $province->id); ?>">View Back Issues</a> And you'll need to have the rest of the html for your modal in your homepage also. Read here, paying attention to the options section: http://twitter.github.com/bootstrap/javascript.html#modals Can't close bootstrap modal called from a controller - El Forum - 03-17-2013 [eluser]Cgull[/eluser] Hi davidMC, Thank you very much for the help. I did read the bootstrap page a few times before posting here, somehow didn't get it. It works great now. God bless you ![]() |