如何在 Sitecore 自定义项目编辑器中利用保存事件?

发布于 2024-09-24 08:18:56 字数 410 浏览 1 评论 0原文

我正在创建一个自定义项目编辑器,并使用以下博客文章作为响应内容编辑器中的“保存”事件的参考,这样我就不需要为我的用户创建第二个令人困惑的“保存”按钮。

http://www.markvanaalst.com/sitecore/creating-a-item -editor/

我能够将我的值保存到项目中,但普通内容选项卡中的值也会被保存,从而覆盖我的值。我已经通过 Firebug 确认了这一点。有没有办法防止这种情况,或者确保我的保存始终在默认保存之后?

我将其作为支持票并在 SDN 上提供,但想知道 SO 社区可以提出什么。

谢谢!

I am creating a custom item editor, and am using the following blog post as a reference for responding to the "save" event in the Content Editor, so that I do not need to create a second, confusing Save button for my users.

http://www.markvanaalst.com/sitecore/creating-a-item-editor/

I am able to save my values to the item, but the values in the normal Content tab are also being saved, overriding my values. I have confirmed this via Firebug. Is there a way to prevent this, or to ensure my save is always after the default save?

I have this in as a support ticket and on SDN as well, but wondering what the SO community can come up with.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空宴 2024-10-01 08:18:56

尝试了基于 iframe 的解决方案,该解决方案使用 IFrame 字段来读取和保存在项目编辑器中输入的值。它需要清理一下,感觉就像一个界面黑客,但它目前似乎正在工作。

在我的项目编辑器中:

jQuery(function () {
    var parentScForm = window.parent.scForm;
    parentScForm.myItemEditor = window;
});


function myGetValue(field) {
    var values = [];
    jQuery('#myForm input[@name="' + field + '"]:checked').each(function () {
        values.push(jQuery(this).val());
    });
    var value = values.join('|');
    return value;
}

在我的 Iframe 字段中:

function scGetFrameValue() {
    var parentScForm = window.parent.scForm;
    if (typeof (parentScForm.myItemEditor) != "undefined") {
        if (typeof (parentScForm.myItemEditor.myGetValue) != "undefined") {
            return parentScForm.myItemEditor.myGetValue("myLists");
        }
    }
    return null;
}

理论上,我可以在项目上有多个字段,这些字段以这种方式“委托”给项目编辑器 - 使用内容编辑器保存而不是试图对抗它。我对“搭便车”到 scForm 上以在我的页面之间进行通信感到有点不安——可能会向我们的常驻 Javascript 黑客咨询更好的方法。

对解决方案有什么意见吗?

编辑:在博客中记录了有关此解决方案的更多信息

Took a shot at an iframe-based solution, which uses an IFrame field to read and save the values being entered in my item editor. It needs to be cleaned up a bit, and feels like an interface hack, but it seems to be working at the moment.

In my item editor:

jQuery(function () {
    var parentScForm = window.parent.scForm;
    parentScForm.myItemEditor = window;
});


function myGetValue(field) {
    var values = [];
    jQuery('#myForm input[@name="' + field + '"]:checked').each(function () {
        values.push(jQuery(this).val());
    });
    var value = values.join('|');
    return value;
}

In my Iframe field:

function scGetFrameValue() {
    var parentScForm = window.parent.scForm;
    if (typeof (parentScForm.myItemEditor) != "undefined") {
        if (typeof (parentScForm.myItemEditor.myGetValue) != "undefined") {
            return parentScForm.myItemEditor.myGetValue("myLists");
        }
    }
    return null;
}

In theory, I could have multiple fields on the item which are "delegated" to the item editor in this way -- working with the content editor save rather than trying to fight against it. I'm a little uneasy about "hitchhiking" onto the scForm to communicate between my pages -- might consult with our resident Javascript hacker on a better method.

Any comments on the solution?

EDIT: Blogged more about this solution

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文