0

我目前正在使用 mvc 4.0 和 IgniteUI 创建一个项目。我正在尝试捆绑 ignite ui 的所有文件...所以我在 web 配置文件中设置了这个

 <system.web>
 <compilation debug="false" targetFramework="4.0" />

我的 bundlesConfig.cs

using System.Web;
using System.Web.Optimization;

namespace LicenciamentoMVC
{
public class BundleConfig
{
    // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

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

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));
        //BundleTable.EnableOptimizations = true;
        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        //bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
        bundles.Add(new StyleBundle("~/Content/css").IncludeDirectory("~/Content/","*.css",true));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
        bundles.Add(new StyleBundle("~/bundles/cssFiles").IncludeDirectory("~/Content/CssIgniteUI/", "*.css", true));
        bundles.Add(new ScriptBundle("~/bundles/jsFiles").IncludeDirectory("~/Scripts/js/", "*.js", true));
    }
 }
}

然后在我想要的视图中,在本例中为 index.cshtml

@{
ViewBag.Title = "Index";
}
@Styles.Render("~/bundles/cssFiles")
@Scripts.Render("~/bundles/jsFiles")

<h2>Index</h2>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

我的文件目录是这样的:项目

-Content
    --CssIgniteUI(Css files of igniteui)
    --themes(default theme css files of asp.net project)
    --Site.css

  -Scripts
    --js(folder containing the js files from igniteui)
    --all the files that come with the default theme of the project

当我尝试打开 Cliente Controler 时……它给了我错误……我错过了什么?该页面不会出现在浏览器上..我正在使用萤火虫查看文件...但是 nthing 显示..

提前致谢..

4

1 回答 1

0

我认为您可能缺少 jQuery UI,因为 ASP.NET MVC4 默认只添加 jQuery 包。Ignite UI 所需资源的正确顺序如下所示:

In _Layout.cshtml:
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@RenderSection("scripts", required: false)

然后直接在其下方或包含在脚本部分中的视图中:

@section scripts{
    @Scripts.Render("~/bundles/jsFiles")
    <!--Ignite UI related script(control definitions) go here-->
}

基本上,jQuery + jQuery UI 需要在 Ignite UI 脚本之前加载。您可以在添加所需资源文档和几乎所有示例中看到这一点,因此我建议您在开始时将它们用作参考。

附带说明一下,由于Ignite UI 主题 CSS 文件也是自定义的 jQuery UI 主题,因此不需要同时包含 jQuery UI CSS(MVC4 中包含在“~/Content/themes/”中的基本主题)。

于 2014-01-23T12:18:59.753 回答