A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
2 Updated url src changes to
source | link

Here's what I ended up doing. I'm sure there's a way to do it in one step though (somehow emulate a shortcut pointing to an item?). If that ever gets posted I'll accept that answer. This does it in multiple steps with a lot of assumptions. It opens a content editor window using the default content editor window id which should be fine. The sketchier parts are where it gets the last window in the scManager.windows array (which SEEMS to be in order). Then blindly setting the url can be improved upon by just looking for the fo parameter and replacing or adding that.

In the success function of an ajax call (data is an id):

success: function (data) {
    var topScForm,
        topScManager,
        contentEditorWindow;

    topScForm = window.top.scForm;
    topScManager = window.top.scManager;

    if (typeof topScForm != 'undefined' && topScForm != null) {
        //open the default content editor shortcut
        topScForm.postRequest('', '', '', 'RunShortcut("{E28353A0-FB68-455B-9B2E-99AD280EF64E}")');

        if (topScManager.windows.length) {
            //get the window we just opened
            contentEditorWindow = topScManager.getWindow(topScManager.windows[topScManager.windows.length - 1]);

            //set the url to open our new item
            contentEditorWindow.src = '/sitecore/shell/Applications/Content%20Editor.aspxContent-Editor?sc_bw=1&fo='ic=Apps%2F48x48%2FPencil.png&he=Content%20Editor&cl=0&fo=' + encodeURIComponent(data);
        }

        //close our dialog
        window.top.dialogClose();
    }
}

Here's what I ended up doing. I'm sure there's a way to do it in one step though (somehow emulate a shortcut pointing to an item?). If that ever gets posted I'll accept that answer. This does it in multiple steps with a lot of assumptions. It opens a content editor window using the default content editor window id which should be fine. The sketchier parts are where it gets the last window in the scManager.windows array (which SEEMS to be in order). Then blindly setting the url can be improved upon by just looking for the fo parameter and replacing or adding that.

In the success function of an ajax call (data is an id):

success: function (data) {
    var topScForm,
        topScManager,
        contentEditorWindow;

    topScForm = window.top.scForm;
    topScManager = window.top.scManager;

    if (typeof topScForm != 'undefined' && topScForm != null) {
        //open the default content editor shortcut
        topScForm.postRequest('', '', '', 'RunShortcut("{E28353A0-FB68-455B-9B2E-99AD280EF64E}")');

        if (topScManager.windows.length) {
            //get the window we just opened
            contentEditorWindow = topScManager.getWindow(topScManager.windows[topScManager.windows.length - 1]);

            //set the url to open our new item
            contentEditorWindow.src = '/sitecore/shell/Applications/Content%20Editor.aspx?sc_bw=1&fo=' + encodeURIComponent(data);
        }

        //close our dialog
        window.top.dialogClose();
    }
}

Here's what I ended up doing. I'm sure there's a way to do it in one step though (somehow emulate a shortcut pointing to an item?). If that ever gets posted I'll accept that answer. This does it in multiple steps with a lot of assumptions. It opens a content editor window using the default content editor window id which should be fine. The sketchier parts are where it gets the last window in the scManager.windows array (which SEEMS to be in order). Then blindly setting the url can be improved upon by just looking for the fo parameter and replacing or adding that.

In the success function of an ajax call (data is an id):

success: function (data) {
    var topScForm,
        topScManager,
        contentEditorWindow;

    topScForm = window.top.scForm;
    topScManager = window.top.scManager;

    if (typeof topScForm != 'undefined' && topScForm != null) {
        //open the default content editor shortcut
        topScForm.postRequest('', '', '', 'RunShortcut("{E28353A0-FB68-455B-9B2E-99AD280EF64E}")');

        if (topScManager.windows.length) {
            //get the window we just opened
            contentEditorWindow = topScManager.getWindow(topScManager.windows[topScManager.windows.length - 1]);

            //set the url to open our new item
            contentEditorWindow.src = '/sitecore/shell/Applications/Content-Editor?ic=Apps%2F48x48%2FPencil.png&he=Content%20Editor&cl=0&fo=' + encodeURIComponent(data);
        }

        //close our dialog
        window.top.dialogClose();
    }
}
1
source | link

Here's what I ended up doing. I'm sure there's a way to do it in one step though (somehow emulate a shortcut pointing to an item?). If that ever gets posted I'll accept that answer. This does it in multiple steps with a lot of assumptions. It opens a content editor window using the default content editor window id which should be fine. The sketchier parts are where it gets the last window in the scManager.windows array (which SEEMS to be in order). Then blindly setting the url can be improved upon by just looking for the fo parameter and replacing or adding that.

In the success function of an ajax call (data is an id):

success: function (data) {
    var topScForm,
        topScManager,
        contentEditorWindow;

    topScForm = window.top.scForm;
    topScManager = window.top.scManager;

    if (typeof topScForm != 'undefined' && topScForm != null) {
        //open the default content editor shortcut
        topScForm.postRequest('', '', '', 'RunShortcut("{E28353A0-FB68-455B-9B2E-99AD280EF64E}")');

        if (topScManager.windows.length) {
            //get the window we just opened
            contentEditorWindow = topScManager.getWindow(topScManager.windows[topScManager.windows.length - 1]);

            //set the url to open our new item
            contentEditorWindow.src = '/sitecore/shell/Applications/Content%20Editor.aspx?sc_bw=1&fo=' + encodeURIComponent(data);
        }

        //close our dialog
        window.top.dialogClose();
    }
}