0

I'm using this https://marketplace.sitecore.net/en/Modules/SymSoft_Event_Calendar_Module.aspx for sitecore and can't seem to get the calender to display. I'm getting an error in firebug TypeError: $ is not a function which is from this script

<script type=text/javascript>
    $(document).ready(function ($) { 
         $('body').FullCalendarWidget('#maincontent_0_content_0_pnlCalendar',
         'http://devosinstitute.umd.edu:80/Ajax/Ajax.ashx?id=e7cbaa1a-c9e3-4aa9-90f8-d2e6baa41fd6&calendars=05120D6A-C8DE-42C1-861A-99C9162CC9B0',
         'prev,next', 
         'title', 
         'month,agendaWeek,agendaDay', 
          false,
          ''
    ); }(jQuery))
</script>

http://placer.ca.gov/EventCalendar.aspx is using the same module for sitecore and I have compared code but can't seem to figure out the issue.

8
  • Looks like jQuery is not correctly attached to page(or isn't attached at all).
    – Anton
    Jul 17, 2015 at 12:14
  • yes <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> just like the website im comparing to.
    – leflis
    Jul 17, 2015 at 12:16
  • Try to change $(document).ready to jQuery(document).ready Jul 17, 2015 at 12:19
  • I can see to figure out where or how that code is being populated. I've looked in the main layout, and various sublayouts.
    – leflis
    Jul 17, 2015 at 12:24
  • 2
    The scoping and call of the self-executing anonymous function is not correct, it should be like this: pastebin.com/yh75mtqG
    – jammykam
    Jul 17, 2015 at 12:40

1 Answer 1

0

The scoping and call of the self-executing anonymous function is not correct, it should be like this:

(function($){
    $(document).ready(function () {
            $('body').FullCalendarWidget('#maincontent_0_content_0_pnlCalendar',
            '/Ajax/Ajax.ashx?id=e7cbaa1a-c9e3-4aa9-90f8-d2e6baa41fd6&calendars=05120D6A-C8DE-42C1-861A-99C9162CC9B0',
            'prev,next',
            'title',
            'month,agendaWeek,agendaDay',
            false,
            ''
        );
    }
})(jQuery);

From your comment, it seems as though the code is directly after the calendar widget panel, so you don't need the document.ready wrapper, since you are guaranteeing that the element already exists. You also don't need the Request.Url.Host and Request.Url.Port, you can just use the absolute path and it will call back to the current domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.