JQuery插件/脚本不适用于ASP.NET MVC 5视图

时间:2014-08-08 23:42:48

标签: c# jquery asp.net-mvc-5

我目前正在努力让这些jQuery插件与我生成的视图一起正常工作。我试图捆绑js / css,如下所示:

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

- > "〜/脚本/ jquery.share.js&#34));

 bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css",
                  "~/Content/jquery.share.css"));

这是HTML和JavaScript本身。

<pre>
<script type="text/javascript">
    $('#mydiv').share({
        networks: ['facebook', 'pinterest', 'googleplus', 'twitter', 'linkedin', 'tumblr', 'email', 'stumbleupon', 'digg'],
        orientation: 'vertical',
        urlToShare: 'http://www.example.com',
        affix: 'left center'
    });
    </script>
</pre>


<div id="mydiv" class="share-affix" style="left: auto; top: 40%;">
    <a class="pop share-icon-twitter" title="Share this page on Twitter" href="#" style="display: block;"></a>
    <a class="pop share-icon-facebook" title="Share this page on Facebook" href="#" style="display: block;"></a>
    <a class="pop share-icon-pinterest" title="Share this page on Pinterest" href="#"></a>
    <a class="pop share-icon-googleplus" title="Share this page on GooglePlus" href="#"></a>
    <a class="pop share-icon-linkedin" title="Share this page on LinkedIn" href="#" style="display: block;"></a>
    <a class="pop share-icon-tumblr" title="Share this page on Tumblr" href="#" style="display: block;"></a>
</div>

1 个答案:

答案 0 :(得分:2)

将此行添加到您的页面中。

 @Styles.Render("~/Content/css/")
 @Scripts.Render("~/bundles/jquery")