November Happy Hour will be moved to Thursday December 5th.

DOJO: add content area items to the empty content area

Vote:
 

Hi All,

I made a function for copying content area items from one content area to another. Everything work great except for the one case: when the target content area is empty. The items are copied but the editor view is not updated as usual. If there are any items in the target content area thene the editor view is updated. In this case when the target content area is empty, I have to switch views or reload/refresh the whole page and than the chages are visible.

Here is the function:

_copyContentAreaItems: function (sourceContentArea, targetContentArea) {
                targetContentArea.focus();
                var emptyCa = false;
                if (!targetContentArea.model.count) {
                    //targetContentArea.model.count = 0;
                    emptyCa = true;
                }
                
                for (let c14 = 0; c14 < sourceContentArea.model.count; c14++) {
                    dojo.when(sourceContentArea.model.getChildByIndex(c14), lang.hitch(this, function (contentData) {
                        targetContentArea.model.modify(lang.hitch(this, function () {                            
                            targetContentArea.model.addChild(contentData);
                        }));

                        console.log("ContentArea copy from " + sourceContentArea.name + " to " + targetContentArea.name, contentData);
                    }));
                }
                console.log("ContentArea copy target[" + targetContentArea.name + "] count: " + targetContentArea.model.count);

                this.focus();
            },

Just to point out that this function is in the custom editor for the property that is not a content area.

Does anybody knows how to initialize that empty content area before adding items? 

Any ideas are welcome :)

#205841
Jul 24, 2019 17:59
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.