Fullcalendar JQuery插件不出现MVC 4 [英] Fullcalendar JQuery plugin not appearing MVC 4

查看:205
本文介绍了Fullcalendar JQuery插件不出现MVC 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这个教程在我的项目中创建了fullcalendar: http://studyoverflow.com/asp-mvc/event-calendar-using-jquery-fullcalendar-in-asp-net-mvc/

I followed this tutorial to make the fullcalendar in my project: http://studyoverflow.com/asp-mvc/event-calendar-using-jquery-fullcalendar-in-asp-net-mvc/

唯一的区别是我已经有了一个项目,并且将Events db添加到了我的上下文中。
这是我的观点:

The only difference is that i already have a project and i added the Events db to my context. This is my view:

<div id="fullcalendar"></div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

    <script type="text/javascript">
        $(function () {
            $('#fullcalendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay'
                },
                defaultDate: new Date(),
                events: "/api/event/"
            });
        });
    </script>
}

和控制器:

And the controller:

 public class EventController : ApiController
    {

        private SGPContext db = new SGPContext();

        // GET api/event
        public IQueryable GetEvents()
        {
            return db.Events;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }

    }
}

我也添加到我的BundleConfig.cs文件中:

I also added this to my BundleConfig.cs file:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                          "~/Scripts/jquery-{version}.js"));

//jQuery fullcalendar plugin css
bundles.Add(new StyleBundle("~/Content/fullcalendar").Include(
                          "~/Content/fullcalendar.css"));

//jQuery fullcalendar plugin js
bundles.Add(new ScriptBundle("~/bundles/fullcalendar").Include(
                          "~/Scripts/moment.js",  //Include the moment.js
                          "~/Scripts/fullcalendar.js"));

当然在NuGet中下载了Jquery.Fullcalendar。
我想我遵循了所有步骤,但它没有显示任何内容......可能缺少什么? Thanls

And of course downloaded the Jquery.Fullcalendar in NuGet. I think i followed all the steps but it doesn't show anything... What can be missing? Thanls

推荐答案

根据评论,正确的答案是包括

As per the comments, the correct answer is to include

@Styles.Render("~/Content/fullcalendar")



在问题视图或_Layout视图中。这将确保日历正确显示。这是从演示中给出的代码中遗漏的。

in either the view in question or the _Layout view. This will ensure the calendar is displayed properly. This was missed from the code given in the demo.

这篇关于Fullcalendar JQuery插件不出现MVC 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆