0

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!

1 Answer 1

0

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

1
  • No other comments or responses, and it's working so far. Accepted. Sep 22, 2010 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.