CodeIgniter Forums

Full Version: [OT] Nav breaks with method call in URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

CI version 3.1.0

I marked as OT because I'm not sure if CI is the problem here.

I'm working on my first CI site (and have wanted to try out CI for years!):

If you notice, there are two drop down menus in the main nav, 'subscribers' and 'events'.

The issue is that those two nav menu's work fine when there is no method called in the URL (hovering enacts the dropdown), but they don't work when there is.... so, for example:

Both work. But:

disables the drop down. Nothing is reported in the console, and this is a nav that I did not build from scratch.. so I'm out of ideas at the moment.

Any thoughts appreciated.

It sounds like your js file is not being found because your js is not working. This is nothing to do with CI.

Taking a quick peek at your code:

<script src='js/device.min.js'></script>

Once a method is used, this link becomes something like:


Rather than as you intended:

You should use:
<script src='/js/device.min.js'></script>
notice the first forward slash making the link use the base domain root, or even better:
PHP Code:
<script src='<?php echo base_url('js/device.min.js'); ?>'></script

This was the first one I found, but you may have others on the page.

Hope that helps,


Base URL in the docs:
Thanks Paul.. your post just made me dig deeper in the javascript (issue was a nested document.write for a .js file ).

And thanks for pointing out the single .js call that I missed with base_url!  by the way, I have been calling base URL such as:
<img src="<?php echo base_url(); ?>images/SA-Logo-Web-507.png" />

Which is a bit different than what you posted... is there a benefit one way or another?

Not really, base_url() will output the base url, base_url('foo/bar') will output the base url with foo/bar on the end.


Personally I prefer to use it with the link inside the function call. I think it is cleaner myself:
PHP Code:
<img src="<?php echo base_url(); ?>images/SA-Logo-Web-507.png" />

img src="<?php echo base_url('images/SA-Logo-Web-507.png'); ?>" /> 

But either is fine.