How to use javascript(js file) in Orchard CMS

后端 未结 4 1504
执念已碎
执念已碎 2020-12-28 18:35

Can any one tell me please how to use js file in Orchard CMS? I added it to Layout.cshtml page as Script.include(\"jquery.js\").

4条回答
  •  -上瘾入骨i
    2020-12-28 18:45

    If you have the Orchard.jQuery module installed and enabled, then at the top of your view use:

    Script.Require("jQuery")
    

    Have a look at the ResourceManifest class in the Orchard.jQuery project (should be somewhere in your Orchard solution file), there you can see all the different jQuery modules you can include using this syntax (e.g. jQueryUI_Core, jQueryUI_Tabs, etc)

    E.g.

     manifest.DefineScript("jQueryUI").SetUrl("jquery-ui.min.js", "jquery-ui.js").SetVersion("1.9.2").SetDependencies("jQuery")
                    .SetCdn("//ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.min.js", "//ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.js", true);
    

提交回复
热议问题