Jquery with Sitecore Page editor
Jquery with Sitecore Page editor
我需要在一行中的第一个单词周围放置span标签。我使用了下面的 Jquery,它在 sitecore 标准模式下运行良好。
$("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>')
})
当我第一次加载页面编辑器时,这也工作正常(通过不插入 span 标签),但是当我创建一个多变量测试时,使用箭头标记在 A/B 之间切换显示,就像插入 span 标签一样,它不应该假设它应该这样做,因为它在页面编辑模式下,但它确实如此并破坏 html,如下所示。
<h2>
<<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"><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&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>
任何建议都会有所帮助。
你可以检查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
}
相关文章:
- CKEditor-我在editor.css中的风格是't
- cpu:phantom:page的比例可以大于1:1:1吗
- 如何在不使用Page.Theme属性的情况下设置页面样式和主题
- 在page.open()-PhantomJS中无法访问全局变量
- 可以't读取'getHTML'未定义的Liferay CK Editor内容
- 向page.includeJs()和page.eevaluate()内的匿名函数传递参数
- Aloha Editor不适用于Opera,有时也不适用于Chrome
- 如何在特定时间重新加载page.php,例如:07:45.非持续时间,例如:每5秒
- ascx page 中的 javascript 抛出 HTTPexception
- 在page.evaluateJavaScript函数中使用PhantomJS变量
- React HTML Editor (TinyMce)
- 如何在页面 Page.IsPostBack 之后禁用 JavaScript 函数
- Javascript Password Page
- jQuery keyUp on Page Load
- 复选框(JSP PAGE)并插入到mysql数据库
- 解析 /page.xhtml 时出错:跟踪错误[行: 42] 与元素类型“id”关联的属性“{1}”应使用左引号
- 在数据库(JSP PAGE)中获取多个复选框结果
- AJAX/page refresh kills JS/jQuery
- Rails应用程序中的每个javascript文件都需要.on('page:change',初始化)吗?
- Jquery with Sitecore Page editor