Sitecore无法保存在Experience Editor中的特殊字符

时间:2016-08-16 13:00:52

标签: sitecore sitecore8

该网站是组件基础网站。在一个组件我有丰富的文本,其中我有70%的东西。将组件添加到页面后,页面上的保存不再起作用。

有人之前有这样的问题吗?

1 个答案:

答案 0 :(得分:0)

这篇文章为我修好了。 请注意我使用的是Sitecore 8.2 Update 2

我的错误:

After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 1, position 2246.

http://jockstothecore.com/experience-editor-error/

postServerRequest: function (requestType, commandContext, handler, async) {

    function normalizeDeviceProp(d) {
        if (typeof(d) !== "object")
            throw new Error("Unexpected presentation details XML: cannot find device property");

        if (d instanceof Array)
            return d;

        var normalized = [];
        normalized.push(d);
        return normalized;
    }

    var token = $('input[name="__RequestVerificationToken"]').val();

    // Custom Brainjocks code to fix Experience Editor error.
    var ajaxData = unescape(JSON.stringify(commandContext));
    if (commandContext && commandContext.scLayout) {
        var obj = JSON.parse(commandContext.scLayout);
      if (obj && obj.r) {
          normalizeDeviceProp(obj.r.d).forEach(function (d) {
              if (d.r instanceof Array) {
                  d.r.forEach(function (r) {
                      var val = r["@par"];
                        if (val && val.length > 0) {
                            ajaxData = ajaxData.replace(unescape(val), val);
                        }
                  });
              }

            });
        }
    }

    jQuery.ajax({
        url: "/-/speak/request/v1/expeditor/" + requestType,
        data: {
            __RequestVerificationToken: token,
            data: ajaxData
        },
        success: handler,
        type: "POST",
        async: async != undefined ? async : false
    });
}