为什么FullCalendar不在这里显示?

时间:2014-07-29 12:54:19

标签: javascript jquery html

我正试图让一个简单的空日历显示在页面上。我已按照http://arshaw.com/fullcalendar/docs/usage/处的文档进行操作,以下代码似乎没问题,因此应显示日历。

我在这里做错了吗?

更新了代码

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Calendar</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

    <!-- Custom styles for this template -->
    <link rel="stylesheet" href="navbar.css">

    <link rel="stylesheet" href="js/fullcalendar-2.0.2/fullcalendar.css">
    <link rel="stylesheet" href="js/fullcalendar-2.0.2/fullcalendar.print.css">

    <script src="js/fullcalendar-2.0.2/lib/jquery.min.js"></script>
    <script src="js/fullcalendar-2.0.2/lib/moment.min.js"></script>
    <script src="js/fullcalendar-2.0.2/fullcalendar.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <script type='text/javascript'>

    $(document).ready(function() {

        // page is now ready, initialize the calendar...

        $('#calendar').fullCalendar({
            // put your options and callbacks here
        })

    });

    </script>
  </head>

  <body>

    <div class="container">

      <!-- Static navbar -->
      <div class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Calendar</a>
          </div>
          <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
              <li class="active"><a href="#">Home</a></li>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Bookings <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="#">Add</a></li>
                  <li><a href="#">Delete</a></li>
                </ul>
              </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
              <li><a href="#">Admin</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div><!--/.container-fluid -->
      </div>

      <!-- Main component to show the calendar-->
      <div id="calendar"></div>

    </div> <!-- /container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  </body>
</html>

截图

http://i.stack.imgur.com/WMUzA.png

1 个答案:

答案 0 :(得分:2)

您正在使用 id #calendar调用元素上的fullCalendar()插件,而您使用 .calendar创建了一个DOM元素。

所以要么改变这一行:

$('#calendar').fullCalendar();

$('.calendar').fullCalendar()

更改此行:

<div class="calendar"></div>

<div id="calendar"></div>