• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to open bootstrap modal window

#1
[eluser]Unknown[/eluser]
I'm new to CodeIgniter and bootstrap and i'm having some problems to open the modal javascript.

Here whats happening, i have a controller x and if i load a page from the index function it all works fine, but if a load from another function my bootstrap modal windows are not opening

Code:
class X extends CI_Controller{
      public function index(){
           $this->load->view('home');
           }
      public function not_index(){
           $this->load->view('home');
           }

My html would be like
Code:
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

Now if i use jquery to open it, only opens when my url is http://mysite/x and when i load from http://mysite/x/not_index it cant open
Code:
$('#myModal').modal('toggle')

i was able to open it using javascript changing the attributes from the id MyModal but i lost the nice effects that bootstrap has. Does anyone knows hot to fix this? Thanks!

#2
[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

How are you including your scripts? Have you made sure that they really are accessible by the source? Are you using the absolute path, or relative path for your scripts?

If you're using Firefox, the Firebug addon can be extremely helpful with debugging these kinds of problems.

#3
[eluser]Unknown[/eluser]
[quote author="TheFuzzy0ne" date="1363969457"]Welcome to the CodeIgniter forums!

How are you including your scripts? Have you made sure that they really are accessible by the source? Are you using the absolute path, or relative path for your scripts?

If you're using Firefox, the Firebug addon can be extremely helpful with debugging these kinds of problems.[/quote]

Thanks TheFuzzyOne i'v changed my includes from relative path to absolut path and is working now

#4
[eluser]TheFuzzy0ne[/eluser]
In your views, when you include scripts or CSS in your views, do the following:
Code:
&lt;link href="&lt;?php echo base_url(); ?&gt;path/to/file.css" type="text/css" rel="stylesheet" /&gt;

That way your paths will be absolute, and will work even if you change your domain name, or run the app in another environment.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.