admin管理员组

文章数量:1025217

I'm trying to add a javascript calendar(link) to my website. So I added the HTML code, attached js and css files. When the page loads I'm getting the following error in the console:

[Error] ReferenceError: Can't find variable: jQuery
    global code (jquery.calendario.js, line 388)
[Error] ReferenceError: Can't find variable: jQuery
    global code (dashboard, line 139)

I checked what's wrong with jquery.calendario.js, line 388 and it has that code: } )( jQuery, window );.

Also in dashboard file, line 139: jQuery(function() {.

Any ideas on how to solve this one?

UPDATE

Header

<!-- Calendar CSS -->
<link href="{% static "css/calendar.css" %}" rel="stylesheet">
<link href="{% static "css/calendar-style.css" %}" rel="stylesheet">
<!-- Modernizr Custom -->
<script src="{% static "js/modernizr.custom.js" %}"></script>

HTML

  <div class="custom-calendar-wrap">
    <div id="custom-inner" class="custom-inner">
      <div class="custom-header clearfix">
        <span id="custom-prev" class="custom-prev"></span> <span id="custom-next" class=
        "custom-next"></span>

        <h2 id="custom-month" class="custom-month"></h2>

        <h3 id="custom-year" class="custom-year"></h3>
      </div>

      <div id="calendar" class="fc-calendar-container"></div>
    </div>
  </div>

Before

<script type="text/javascript" src="{% static "js/jquery.calendario.js" %}"></script>
<script type="text/javascript" src="{% static "js/data.js" %}"></script>
<script type="text/javascript">
    jQuery(function() {

        var transEndEventNames = {
                'WebkitTransition' : 'webkitTransitionEnd',
                'MozTransition' : 'transitionend',
                'OTransition' : 'oTransitionEnd',
                'msTransition' : 'MSTransitionEnd',
                'transition' : 'transitionend'
            },
            transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
            $wrapper = $( '#custom-inner' ),
            $calendar = $( '#calendar' ),
            cal = $calendar.calendario( {
                onDayClick : function( $el, $contentEl, dateProperties ) {

                    if( $contentEl.length > 0 ) {
                        showEvents( $contentEl, dateProperties );
                    }

                },
                caldata : codropsEvents,
                displayWeekAbbr : true
            } ),
            $month = $( '#custom-month' ).html( cal.getMonthName() ),
            $year = $( '#custom-year' ).html( cal.getYear() );

        $( '#custom-next' ).on( 'click', function() {
            cal.gotoNextMonth( updateMonthYear );
        } );
        $( '#custom-prev' ).on( 'click', function() {
            cal.gotoPreviousMonth( updateMonthYear );
        } );

        function updateMonthYear() {
            $month.html( cal.getMonthName() );
            $year.html( cal.getYear() );
        }

        // just an example..
        function showEvents( $contentEl, dateProperties ) {

            hideEvents();

            var $events = $( '<div id="custom-content-reveal" class="custom-content-reveal"><h4>Events for ' + dateProperties.monthname + ' ' + dateProperties.day + ', ' + dateProperties.year + '</h4></div>' ),
                $close = $( '<span class="custom-content-close"></span>' ).on( 'click', hideEvents );

            $events.append( $contentEl.html() , $close ).insertAfter( $wrapper );

            setTimeout( function() {
                $events.css( 'top', '0%' );
            }, 25 );

        }
        function hideEvents() {

            var $events = $( '#custom-content-reveal' );
            if( $events.length > 0 ) {

                $events.css( 'top', '100%' );
                Modernizr.csstransitions ? $events.on( transEndEventName, function() { $( this ).remove(); } ) : $events.remove();

            }

        }

    });
</script>

Ps. It's a django project hence the {% static "..." %}.

I'm trying to add a javascript calendar(link) to my website. So I added the HTML code, attached js and css files. When the page loads I'm getting the following error in the console:

[Error] ReferenceError: Can't find variable: jQuery
    global code (jquery.calendario.js, line 388)
[Error] ReferenceError: Can't find variable: jQuery
    global code (dashboard, line 139)

I checked what's wrong with jquery.calendario.js, line 388 and it has that code: } )( jQuery, window );.

Also in dashboard file, line 139: jQuery(function() {.

Any ideas on how to solve this one?

UPDATE

Header

<!-- Calendar CSS -->
<link href="{% static "css/calendar.css" %}" rel="stylesheet">
<link href="{% static "css/calendar-style.css" %}" rel="stylesheet">
<!-- Modernizr Custom -->
<script src="{% static "js/modernizr.custom.js" %}"></script>

HTML

  <div class="custom-calendar-wrap">
    <div id="custom-inner" class="custom-inner">
      <div class="custom-header clearfix">
        <span id="custom-prev" class="custom-prev"></span> <span id="custom-next" class=
        "custom-next"></span>

        <h2 id="custom-month" class="custom-month"></h2>

        <h3 id="custom-year" class="custom-year"></h3>
      </div>

      <div id="calendar" class="fc-calendar-container"></div>
    </div>
  </div>

Before

<script type="text/javascript" src="{% static "js/jquery.calendario.js" %}"></script>
<script type="text/javascript" src="{% static "js/data.js" %}"></script>
<script type="text/javascript">
    jQuery(function() {

        var transEndEventNames = {
                'WebkitTransition' : 'webkitTransitionEnd',
                'MozTransition' : 'transitionend',
                'OTransition' : 'oTransitionEnd',
                'msTransition' : 'MSTransitionEnd',
                'transition' : 'transitionend'
            },
            transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
            $wrapper = $( '#custom-inner' ),
            $calendar = $( '#calendar' ),
            cal = $calendar.calendario( {
                onDayClick : function( $el, $contentEl, dateProperties ) {

                    if( $contentEl.length > 0 ) {
                        showEvents( $contentEl, dateProperties );
                    }

                },
                caldata : codropsEvents,
                displayWeekAbbr : true
            } ),
            $month = $( '#custom-month' ).html( cal.getMonthName() ),
            $year = $( '#custom-year' ).html( cal.getYear() );

        $( '#custom-next' ).on( 'click', function() {
            cal.gotoNextMonth( updateMonthYear );
        } );
        $( '#custom-prev' ).on( 'click', function() {
            cal.gotoPreviousMonth( updateMonthYear );
        } );

        function updateMonthYear() {
            $month.html( cal.getMonthName() );
            $year.html( cal.getYear() );
        }

        // just an example..
        function showEvents( $contentEl, dateProperties ) {

            hideEvents();

            var $events = $( '<div id="custom-content-reveal" class="custom-content-reveal"><h4>Events for ' + dateProperties.monthname + ' ' + dateProperties.day + ', ' + dateProperties.year + '</h4></div>' ),
                $close = $( '<span class="custom-content-close"></span>' ).on( 'click', hideEvents );

            $events.append( $contentEl.html() , $close ).insertAfter( $wrapper );

            setTimeout( function() {
                $events.css( 'top', '0%' );
            }, 25 );

        }
        function hideEvents() {

            var $events = $( '#custom-content-reveal' );
            if( $events.length > 0 ) {

                $events.css( 'top', '100%' );
                Modernizr.csstransitions ? $events.on( transEndEventName, function() { $( this ).remove(); } ) : $events.remove();

            }

        }

    });
</script>

Ps. It's a django project hence the {% static "..." %}.

Share Improve this question edited Apr 13, 2014 at 2:17 manosim asked Apr 13, 2014 at 2:08 manosimmanosim 3,69013 gold badges47 silver badges68 bronze badges 4
  • 1 1. have you included jQuery as well as your calendar script? 2. have you included it before the calendar script? – scrowler Commented Apr 13, 2014 at 2:11
  • Add JQuery references to your HTML. – PM 77-1 Commented Apr 13, 2014 at 2:11
  • learn.jquery./about-jquery/how-jquery-works – Felix Kling Commented Apr 13, 2014 at 2:11
  • @scrowler I added the code in the question so you can see the order. – manosim Commented Apr 13, 2014 at 2:20
Add a ment  | 

1 Answer 1

Reset to default 2

Did you add the jQuery library file to your html document?

Header

<head>
<script src="http://ajax.googleapis./ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
</head>

I'm trying to add a javascript calendar(link) to my website. So I added the HTML code, attached js and css files. When the page loads I'm getting the following error in the console:

[Error] ReferenceError: Can't find variable: jQuery
    global code (jquery.calendario.js, line 388)
[Error] ReferenceError: Can't find variable: jQuery
    global code (dashboard, line 139)

I checked what's wrong with jquery.calendario.js, line 388 and it has that code: } )( jQuery, window );.

Also in dashboard file, line 139: jQuery(function() {.

Any ideas on how to solve this one?

UPDATE

Header

<!-- Calendar CSS -->
<link href="{% static "css/calendar.css" %}" rel="stylesheet">
<link href="{% static "css/calendar-style.css" %}" rel="stylesheet">
<!-- Modernizr Custom -->
<script src="{% static "js/modernizr.custom.js" %}"></script>

HTML

  <div class="custom-calendar-wrap">
    <div id="custom-inner" class="custom-inner">
      <div class="custom-header clearfix">
        <span id="custom-prev" class="custom-prev"></span> <span id="custom-next" class=
        "custom-next"></span>

        <h2 id="custom-month" class="custom-month"></h2>

        <h3 id="custom-year" class="custom-year"></h3>
      </div>

      <div id="calendar" class="fc-calendar-container"></div>
    </div>
  </div>

Before

<script type="text/javascript" src="{% static "js/jquery.calendario.js" %}"></script>
<script type="text/javascript" src="{% static "js/data.js" %}"></script>
<script type="text/javascript">
    jQuery(function() {

        var transEndEventNames = {
                'WebkitTransition' : 'webkitTransitionEnd',
                'MozTransition' : 'transitionend',
                'OTransition' : 'oTransitionEnd',
                'msTransition' : 'MSTransitionEnd',
                'transition' : 'transitionend'
            },
            transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
            $wrapper = $( '#custom-inner' ),
            $calendar = $( '#calendar' ),
            cal = $calendar.calendario( {
                onDayClick : function( $el, $contentEl, dateProperties ) {

                    if( $contentEl.length > 0 ) {
                        showEvents( $contentEl, dateProperties );
                    }

                },
                caldata : codropsEvents,
                displayWeekAbbr : true
            } ),
            $month = $( '#custom-month' ).html( cal.getMonthName() ),
            $year = $( '#custom-year' ).html( cal.getYear() );

        $( '#custom-next' ).on( 'click', function() {
            cal.gotoNextMonth( updateMonthYear );
        } );
        $( '#custom-prev' ).on( 'click', function() {
            cal.gotoPreviousMonth( updateMonthYear );
        } );

        function updateMonthYear() {
            $month.html( cal.getMonthName() );
            $year.html( cal.getYear() );
        }

        // just an example..
        function showEvents( $contentEl, dateProperties ) {

            hideEvents();

            var $events = $( '<div id="custom-content-reveal" class="custom-content-reveal"><h4>Events for ' + dateProperties.monthname + ' ' + dateProperties.day + ', ' + dateProperties.year + '</h4></div>' ),
                $close = $( '<span class="custom-content-close"></span>' ).on( 'click', hideEvents );

            $events.append( $contentEl.html() , $close ).insertAfter( $wrapper );

            setTimeout( function() {
                $events.css( 'top', '0%' );
            }, 25 );

        }
        function hideEvents() {

            var $events = $( '#custom-content-reveal' );
            if( $events.length > 0 ) {

                $events.css( 'top', '100%' );
                Modernizr.csstransitions ? $events.on( transEndEventName, function() { $( this ).remove(); } ) : $events.remove();

            }

        }

    });
</script>

Ps. It's a django project hence the {% static "..." %}.

I'm trying to add a javascript calendar(link) to my website. So I added the HTML code, attached js and css files. When the page loads I'm getting the following error in the console:

[Error] ReferenceError: Can't find variable: jQuery
    global code (jquery.calendario.js, line 388)
[Error] ReferenceError: Can't find variable: jQuery
    global code (dashboard, line 139)

I checked what's wrong with jquery.calendario.js, line 388 and it has that code: } )( jQuery, window );.

Also in dashboard file, line 139: jQuery(function() {.

Any ideas on how to solve this one?

UPDATE

Header

<!-- Calendar CSS -->
<link href="{% static "css/calendar.css" %}" rel="stylesheet">
<link href="{% static "css/calendar-style.css" %}" rel="stylesheet">
<!-- Modernizr Custom -->
<script src="{% static "js/modernizr.custom.js" %}"></script>

HTML

  <div class="custom-calendar-wrap">
    <div id="custom-inner" class="custom-inner">
      <div class="custom-header clearfix">
        <span id="custom-prev" class="custom-prev"></span> <span id="custom-next" class=
        "custom-next"></span>

        <h2 id="custom-month" class="custom-month"></h2>

        <h3 id="custom-year" class="custom-year"></h3>
      </div>

      <div id="calendar" class="fc-calendar-container"></div>
    </div>
  </div>

Before

<script type="text/javascript" src="{% static "js/jquery.calendario.js" %}"></script>
<script type="text/javascript" src="{% static "js/data.js" %}"></script>
<script type="text/javascript">
    jQuery(function() {

        var transEndEventNames = {
                'WebkitTransition' : 'webkitTransitionEnd',
                'MozTransition' : 'transitionend',
                'OTransition' : 'oTransitionEnd',
                'msTransition' : 'MSTransitionEnd',
                'transition' : 'transitionend'
            },
            transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
            $wrapper = $( '#custom-inner' ),
            $calendar = $( '#calendar' ),
            cal = $calendar.calendario( {
                onDayClick : function( $el, $contentEl, dateProperties ) {

                    if( $contentEl.length > 0 ) {
                        showEvents( $contentEl, dateProperties );
                    }

                },
                caldata : codropsEvents,
                displayWeekAbbr : true
            } ),
            $month = $( '#custom-month' ).html( cal.getMonthName() ),
            $year = $( '#custom-year' ).html( cal.getYear() );

        $( '#custom-next' ).on( 'click', function() {
            cal.gotoNextMonth( updateMonthYear );
        } );
        $( '#custom-prev' ).on( 'click', function() {
            cal.gotoPreviousMonth( updateMonthYear );
        } );

        function updateMonthYear() {
            $month.html( cal.getMonthName() );
            $year.html( cal.getYear() );
        }

        // just an example..
        function showEvents( $contentEl, dateProperties ) {

            hideEvents();

            var $events = $( '<div id="custom-content-reveal" class="custom-content-reveal"><h4>Events for ' + dateProperties.monthname + ' ' + dateProperties.day + ', ' + dateProperties.year + '</h4></div>' ),
                $close = $( '<span class="custom-content-close"></span>' ).on( 'click', hideEvents );

            $events.append( $contentEl.html() , $close ).insertAfter( $wrapper );

            setTimeout( function() {
                $events.css( 'top', '0%' );
            }, 25 );

        }
        function hideEvents() {

            var $events = $( '#custom-content-reveal' );
            if( $events.length > 0 ) {

                $events.css( 'top', '100%' );
                Modernizr.csstransitions ? $events.on( transEndEventName, function() { $( this ).remove(); } ) : $events.remove();

            }

        }

    });
</script>

Ps. It's a django project hence the {% static "..." %}.

Share Improve this question edited Apr 13, 2014 at 2:17 manosim asked Apr 13, 2014 at 2:08 manosimmanosim 3,69013 gold badges47 silver badges68 bronze badges 4
  • 1 1. have you included jQuery as well as your calendar script? 2. have you included it before the calendar script? – scrowler Commented Apr 13, 2014 at 2:11
  • Add JQuery references to your HTML. – PM 77-1 Commented Apr 13, 2014 at 2:11
  • learn.jquery./about-jquery/how-jquery-works – Felix Kling Commented Apr 13, 2014 at 2:11
  • @scrowler I added the code in the question so you can see the order. – manosim Commented Apr 13, 2014 at 2:20
Add a ment  | 

1 Answer 1

Reset to default 2

Did you add the jQuery library file to your html document?

Header

<head>
<script src="http://ajax.googleapis./ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
</head>

本文标签: jQueryJavascriptCan39t find variableStack Overflow