iamphill / Bootstrap-Offcanvas

:zap: Offcanvas menu built with Bootstrap
MIT License
367 stars 111 forks source link

Uncaught TypeError: undefined is not a function #9

Closed DaveLindberg closed 9 years ago

DaveLindberg commented 9 years ago

I'm getting the following error when loading my page with bootstrap.offcanvas.js installed:

Uncaught TypeError: undefined is not a functionbootstrap.offcanvas.js?ver=4.0:229 (anonymous function)bootstrap.offcanvas.js?ver=4.0:253 (anonymous function)

Loading bootstrap.offcanvas.min.js produces the same result.

iamphill commented 9 years ago

@DaveLindberg What line is the error on? Do you get the error on http://iamphill.github.io/Bootstrap-Offcanvas/example.html?

DaveLindberg commented 9 years ago

http://iamphill.github.io/Bootstrap-Offcanvas/example.html is coming up clean.

Looks like the error (on my install) is on line 229. JSHint throws warnings on: line 233 return oc = "Did you mean to return a conditional instead of an assignment? — column 18" line 237 return $(this).on('click', function(e) { "'e' is defined but never used. — column 43" I installed the components using bower.

iamphill commented 9 years ago

@DaveLindberg Hmm.. 229 would be https://github.com/iamphill/Bootstrap-Offcanvas/blob/master/dist/js/bootstrap.offcanvas.js#L229 which would surely mean that $ isn't available. jQuery is available right?

DaveLindberg commented 9 years ago

Confirmed, jQuery is loading properly — before the bootstrap.offcanvas.js

iamphill commented 9 years ago

@DaveLindberg Could you upload a demo somewhere where it isn't working?

DaveLindberg commented 9 years ago

See http://webdev.davelindberg.com/

iamphill commented 9 years ago

@DaveLindberg Ah I see the issue, angularJS redefines the $ variable. Will get a fix out ASAP.

DaveLindberg commented 9 years ago

Fantastic, thanks!

iamphill commented 9 years ago

@DaveLindberg Just released 1.3.5 if you could try that.

DaveLindberg commented 9 years ago

I've posted the v1.3.5 version to http://webdev.davelindberg.com/ Still getting an error. Line 149?

iamphill commented 9 years ago

@DaveLindberg Just checked your demo, and it is still showing the older version?

Just created a PR anyway with a test. Could you try using #10 ?

DaveLindberg commented 9 years ago

10 is working fine on my local install. Oddly, it still throws an error on webdev. I've check the two files and found no diff, not sure what's happening here?

iamphill commented 9 years ago

@DaveLindberg Your one http://webdev.davelindberg.com/wp-content/themes/angwobo/bower_components/bootstrap-offcanvas/dist/js/bootstrap.offcanvas.js?ver=4.1.1 looks different to https://raw.githubusercontent.com/iamphill/Bootstrap-Offcanvas/dollar-fix/dist/js/bootstrap.offcanvas.js

DaveLindberg commented 9 years ago

Thx. Not sure why, but there's a trailing newline on the webdev version that I can't get rid of — don't know why. Other than that, the latest version should be in place.

And yes, this fix does the job nicely on my local server.

iamphill commented 9 years ago

@DaveLindberg Cool, will get it merged in.

Styling on your version is off. Looks like you haven't included Bootstrap.