Amod Amod - 15 days ago 5
HTML Question

Undefined is not a function... BUT... it's working in a stand alone demo file

I am trying to get this effect running: http://mmenu.frebsite.nl/examples.html
Its a simple popup that's responsive and can be used to show content on demand.


  1. My
    <head>
    includes jquery 2.0.2 and jquery-ui, they are being successfully loaded.

  2. Then I include the script for the above effect:

    <script type="text/javascript" href="/media/jquery.mmenu.min.all.js"></script>

  3. Finally, just below the body ends, I include this:

    <script type="text/javascript">
    $(document).ready(function() {
    var options = {
    classes : 'mm-light',
    modal : true
    };
    options.position = 'left';
    options.zposition = 'front';
    $("#popup-1").mmenu( options );
    $('a.close').click(function() {
    $(this).closest( '.mm-menu' ).trigger( 'close' );
    });
    });
    </script>



I am getting an "undefined is not a function" error for the

$("#popup-1").mmenu( options );


line...

Weirdly... when running the demo locally (without anything else on the page), it works perfectly...
so what could be going wrong in the main website version? Any leads?

Answer

<script> tags use a src attribute, not href !

Your attempt to load the mmenu plugin is effectively a no-op. Without a src attribute it won't even produce a 404 error, it'll look like an empty inline script.

Comments