8

行の最初の単語の周りにスパンタグを配置する必要があります。サイトコア標準モードで正常に動作する以下の Jquery を使用しました。

$("body").has(".widget h2").addClass("standard-mode");
$("body").has(".scLoadingIndicatorInner").removeClass("standard-mode").addClass("page-edit");


$('.standard-mode .widget h2').html(function(i, html){
    return html.replace(/(\w+\s)/, '<span>$1</span>')
})

最初にページ エディターをロードしたとき、これも (スパン タグを挿入しないことで) 正常に動作しますが、矢印マークを使用して A/B を切り替える多変量テストを作成すると、想定すべきではないスパン タグを挿入するように表示されます。ページ編集モードでそのまま実行しますが、実行し、以下のように html を壊します。

<h2>
        &lt;<span>input </span>id="fld_D26C954B73BE4C62B6F25BE191A86F18_7B55B5E5EDD84D4E88B16C6E073495A5_en_1_0e80a9c63ab6419f8135b70511e892f1_16487" class="scFieldValue" name="fld_D26C954B73BE4C62B6F25BE191A86F18_7B55B5E5EDD84D4E88B16C6E073495A5_en_1_0e80a9c63ab6419f8135b70511e892f1_16487" type="hidden" value="Badger Cull"&gt;<span class="scChromeData">{"commands":[{"click":"chrome:common:edititem({command:\"webedit:open\"})","header":"Edit the related item","icon":"/temp/IconCache/SoftwareV2/16x16/cubes_blue.png","disabledIcon":"/temp/cubes_blue_disabled16x16.png","isDivider":false,"tooltip":"Edit this item in the Content Editor.","type":"common"},{"click":"chrome:rendering:personalize({command:\"webedit:personalize\"})","header":"Personalize","icon":"/temp/IconCache/PeopleV2/16x16/users3_edit.png","disabledIcon":"/temp/users3_edit_disabled16x16.png","isDivider":false,"tooltip":"Personalize component.","type":"sticky"},{"click":"javascript:Sitecore.PageModes.PageEditor.postRequest('ActiveISPageEditor:publish(id={D26C954B-73BE-4C62-B6F2-5BE191A86F18})',null,false)","header":"Publish the related item","icon":"/temp/IconCache/Network/16x16/download.png","disabledIcon":"/temp/download_disabled16x16.png","isDivider":false,"tooltip":"Publish this item.","type":"common"},{"click":"chrome:rendering:editvariations({command:\"webedit:editvariations\"})","header":"Edit variations","icon":"/temp/IconCache/SoftwareV2/16x16/breakpoints.png","disabledIcon":"/temp/breakpoints_disabled16x16.png","isDivider":false,"tooltip":"Edit the variations.","type":"sticky"}],"contextItemUri":"sitecore://master/{D26C954B-73BE-4C62-B6F2-5BE191A86F18}?lang=en&amp;ver=1","custom":{},"displayName":"Header Text","expandedDisplayName":null}</span><span scfieldtype="single-line text" sc_parameters="prevent-line-break=true" contenteditable="false" class="scWebEditInput scEnabledChrome" id="fld_D26C954B73BE4C62B6F25BE191A86F18_7B55B5E5EDD84D4E88B16C6E073495A5_en_1_0e80a9c63ab6419f8135b70511e892f1_16487_edit" sc-part-of="field">Badger Cull</span>
    </h2>

どんな提案も役に立ちます。

4

1 に答える 1

12

JavaScript プロパティSitecore.PageModes.PageEditorをチェックして、ページ エディター モードであるかどうかを確認し、それに応じて JavaScript を無効にすることができます。

function isPageEditor() {
    if (typeof Sitecore == "undefined") {
        return false;
    }
    if (typeof Sitecore.PageModes == "undefined" || Sitecore.PageModes == null) {
        return false;
    }
    return Sitecore.PageModes.PageEditor != null;
}

if (isPageEditor() == false) {
    //do your stuff here   
}
于 2014-04-09T15:17:40.390 に答える