How to implement $ ('# calendar'). weekCalendar ('today')?

I know very little about javascript, so I'm not quite sure what I am doing. Our team is mainly working on a project that uses jQuery weekcalendar javascript. By default, the calendar will be displayed for a whole week.

My problem is this: I have several css files that are suitable for different screens, which I call using another javascript. For the smallest screen resolution, the one I call for mobile phones and the entire calendar will not correspond to the specified width for this resolution, so I only need to display the current day. I found on sites that I need to use $('#calendar').weekCalendar("today"), but I can’t figure out how to implement it and what I should use for the if statement.

This is what the code I tried looks like,

<script type="text/javascript">
$(document).ready(function () {
    if (document.styleSheets('mobile.min.css')) {
        $('#calendar').weekCalendar('today');
    }
})

Obviously, this does not work, and I believe that it is wrong. Can someone please help me? Thank.

+5
source share
1 answer

Adapt js, , , . , , .

, ADAPT CONFIG .

callback: ChangeCalendar

script js . , . switch .

ChangeCalendar(index, width)
{
    switch (index) {
       // handles the first item in the range (0 to 760px)
     case 0: $('#calendar').weekCalendar('today');
     break;
      // handles the second item in the range (760 to 980px)
    case 1: //something else
      break;
    // handles everything we missed
    default:
    break;
   }
}

, , width, if , if (width > 950) {etc}

, .

+1

All Articles