I'm actually working on the same features for our new implementation.
In Content editor, you might need to update core db.
In xEditor, you can use sitecore JS commands with ajax and back-end codes. My suggestion is that you can create a rendering component and assign the component into the named placeholder instead of remvoing it. Then, call the back-end and javascript events on the rendering item.
This could be a starting point.
Javascript
function:
function setDataSrc(itemID, templatePath, suffix, renderingID, dbName, deviceID, renderingUID, reload, callBack) {
var postReq = $.post("/handlePostRequest.aspx (or .cshtml)", {
method: 'methodName'
, itemID: itemID
, templatePath: templatePath
, suffix: suffix
, renderingID: renderingID
, dbName: dbName
, deviceID: deviceID
, renderingUID: renderingUID
});
postReq.done(function (data) {
if (reload != false) {
location.reload(true);
}
if (typeof callBack == 'function') {
callBack(data);
}
});
}