I want to localize a Component, and then edit some stuff in it.
function loadCompOnLocalize(e) {
var localizedSeoComponent = e.source;
if (localizedSeoComponent.isLocalized()) {//do stuff}
}
function loadCompOnLocalizeFailed(e) {//do other suff}
function seoComponentAfterLoad(component) {
if (component.isLocalized()) {
$log.debug("Component '{0}' is already localized.", childComponentId);
} else {
$evt.addEventHandler(component, "load", loadCompOnLocalize);
$evt.addEventHandler(component, "loadfailed", loadCompOnLocalizeFailed);
component.localize(true);
}
function seoComponentLoad(e) {
$evt.removeEventHandler(e.source, "load", seoComponentLoad);
$evt.removeEventHandler(e.source, "loadfailed", seoComponentLoadFailed);
seoComponentAfterLoad(e.source);
};
function seoComponentLoadFailed(e) {
$evt.removeEventHandler(e.source, "load", seoComponentLoad);
$evt.removeEventHandler(e.source, "loadfailed", seoComponentLoadFailed);
$log.debug("Failed to load seo component '{0}'", childComponentId);
};
if (childComponent.isLoaded()) {
seoComponentAfterLoad(childComponent);
} else {
$evt.addEventHandler(childComponent, "load", seoComponentLoad);
$evt.addEventHandler(childComponent, "loadfailed", seoComponentLoadFailed);
childComponent.load(true, $const.OpenMode.VIEW);
}
The problem is that when it enters loadCompOnLocalize
, the Component returns false for .isLocalized()
.
On the configuration side: I have the Tridion.Web.UI.Core.Communicator
disabled in configuration (because is like this in production). If is enabled, it works fine, because when it enters the handler for "load", the Component it has the correct value for isLocalized()
. But when is disabled, there is no way I can check when the Component finished to be localized.