Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Bootstrap 3 Modal Not Loading Up
#1

[eluser]razerone[/eluser]
Hi.

I am working on my modal popup for bootstrap 3 and trying to make it work with codeigniter. It will not load up in the view.

I have got it working on my standard html http://codepen.io/CarraraWebsiteSolutions/pen/uzhfj. But will not work on PHP Codeigniter. I have been stuck on it all night.

Why wont it load on my view. my view is home.php Javascript is kept in bottom of footer is what bootstrap recommends

Code:
type="text/javascript"
$('#myModal').modal('toggle')

In the home controller is

Code:
$this->load->view(header);
$this->load->view(home);
$this->load->view(footer);

In the home view is

Code:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>This Is A Modal Pop Up</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>&lt;!-- /.modal-content --&gt;
</div>&lt;!-- /.modal-dialog --&gt;
</div>&lt;!-- /.modal --&gt;
#2

[eluser]noideawhattotypehere[/eluser]
So, first you call a function THEN you add a .js file? No way it doesnt work!

PS: Get firebug.
PS2: document.ready() is a very useful thing.
#3

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1383055399"]So, first you call a function THEN you add a .js file? No way it doesnt work!

PS: Get firebug.[/quote]

Didn't know that I am just starting to learning trying to teach my self every thing have been looking through google all day JS How Do I Call It.
#4

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1383055399"]So, first you call a function THEN you add a .js file? No way it doesnt work!

PS: Get firebug.
PS2: document.ready() is a very useful thing.[/quote]


$( document ).ready(function() {
$('#myModal').modal('toggle');
});
#5

[eluser]noideawhattotypehere[/eluser]
Yeah, now get Firefox+Firebug and you will catch every single JS error.
#6

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1383056372"]Yeah, now get Firefox+Firebug and you will catch every single JS error.[/quote]

Says type error

TypeError: $(...).modal is not a function
$('#myModal').modal('toggle')

[removed]
$( document ).ready(function() {
$('#myModal').modal('toggle');
});
[removed]
#7

[eluser]noideawhattotypehere[/eluser]
Why dont you place all your .js in the head section of your document? You are still calling a .modal() function before having it loaded in your document.
#8

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1383056557"]Why dont you place all your .js in the head section of your document? You are still calling a .modal() function before having it loaded in your document.[/quote]

It give up on that now still not working thanks for help any way. I placed it in the head gave that ago also gave it ago placing in bottom of footer.

I might have to do more reading on this. works fine with normal html
#9

[eluser]noideawhattotypehere[/eluser]
You had to screw something up in your view then, you get 'normal html' from CodeIgniter too. PHP is a server side language, all your browser gets is a html response.
#10

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1383057372"]You had to screw something up in your view then, you get 'normal html' from CodeIgniter too. PHP is a server side language, all your browser gets is a html response.[/quote]

Would you think need to load javascript helper




Theme © iAndrew 2016 - Forum software by © MyBB