@Html.Kentico().PageBuilderScripts() renders inline editor scripts on frontend

Dmitry Bastron asked on August 2, 2019 18:14

Hi guys,

I'm stuck with the following problem. I've got these calls in my view:

@section styles
{
    @Html.Kentico().PageBuilderStyles()
}

@section scripts
{
    @Html.Kentico().PageBuilderScripts()
}

Also, as it should be, have these in my layout:

@RenderSection("styles", required: false)
...
@RenderSection("scripts", required: false)

But in the result markup on live site (not admin) I see all the admin scripts and styles referenced:

<link href="/MySite/Content/FormComponents/TaxonomySelectorComponent/taxonomy-editor.css" rel="stylesheet"/>
<link href="/MySite/Content/FormComponents/TaxonomySelectorComponent/jsTree/themes/default/style.css" rel="stylesheet"/>
<link href="/MySite/Content/FormComponents/TaxonomySelectorComponent/jsTree/themes/default/style.min.css" rel="stylesheet"/>
...
<script src="/MySite/Kentico/Content/FormComponents/FileUploader/file-uploader.js"></script>
<script src="/MySite/Kentico/Content/Selectors/FormComponents/MediaFiles/media-files-selector.admin.js"></script>
<script src="/MySite/Kentico/Content/Selectors/FormComponents/Pages/page-selector.admin.js"></script>
<script src="/MySite/Kentico/Content/Selectors/FormComponents/Path/path-selector.admin.js"></script>
<script src="/MySite/Content/FormComponents/TaxonomySelectorComponent/taxonomy-editor.js"></script>
<script src="/MySite/Content/FormComponents/TaxonomySelectorComponent/jsTree/jstree.js"></script>
<script src="/MySite/Kentico/Scripts/forms/updatableFormHelper.js"></script>
<script src="/MySite/Kentico/Content/FormComponents/USPhone/dependencyLibs/inputmask.dependencyLib.js"></script>
<script src="/MySite/Kentico/Content/FormComponents/USPhone/inputmask.js"></script>

Any ideas why this might be happening?

Recent Answers


Zach Perry answered on August 2, 2019 18:32

I am guessing it thinks you are in Edit mode for some reason.

Maybe try this in the view, not sure if it will help because it should be checking for it inside PageBuilderStyles?

@section styles
{
    @if (HttpContext.Current.Kentico().PageBuilder().EditMode)
    {
        @Html.Kentico().PageBuilderStyles()
    }
}
0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 2, 2019 18:48

Thanks Zach, I originally had this one. It works fine with the styles, but if you disable the scripts this way Forms built with Forms Builder stop working. I guess they require some jquery or something to work.

Strange thing is that it works fine in default Dancing Goat MVC website without EditMode check. And I just can't figure out why?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.