Add .JS in Homepage

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 anos atrás
Hi, I'm new with this NopCommerce, and I'm just testing to see how it works.

I'm trying to add this code in the Index.cshtml, but nothing changed.

Somebody can give me a hint please?

Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/curvedLines.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/excanvas.min.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.colorhelpers.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.canvas.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.categories.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.crosshair.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.errorbars.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.fillbetween.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.image.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.navigate.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.pie.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.resize.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.selection.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.spline.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.stack.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.symbol.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.threshold.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.time.js");
    Html.AddScriptParts("~/Themes/DefaultClean/Scripts/js/jquery.flot.tooltip.min.js");

<div id="flot-dashboard-chart"></div>

@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {

            //#Code for the chart#

            $.plot($("#flot-dashboard-chart"), dataset, options);
        });
    </script>
}
7 anos atrás
I'm also a newbie.

Try _Root.Head.cshtml from Nop.Web/Views/Shared ?
7 anos atrás
Yes...  /Views/Shared/_Root.Head.cshtml  is probably your best option.
3 anos atrás
Add $
example;

Html.AddScriptParts($"~/Themes/DefaultClean/Scripts/js/curvedLines.js");


OR Example two (in Home index.cshtml);

@inject IThemeContext themeContext /* FD toflabs */
@{
    Layout = "_ColumnsOne";

    //page class
    Html.AppendPageCssClassParts("html-home-page");

  
  @* Owl Stylesheets*@
        var themeName = themeContext.WorkingThemeName;/* FD toflabs */
        Html.AppendCssFileParts($"~/Themes/{themeName}/Content/file.css");/* FD toflabs */        
        Html.AppendCssFileParts($"~/Themes/{themeName}/Content/file.min.css"); /* FD toflabs */
        Html.AppendScriptParts($"~/Themes/{themeName}/Content/file.js");
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.