User eda6f877b4
11-09-2014 10:46:22
Hi
I am working on a solution like the example edit-images.
Most of it is working OK, but I am having trouble getting a reference to my sketcher instance. I am using Telerik control (RadWindow) to open the iframe. The iframe is created once the image is clicked and not on page load.
Code block 'oWnd.show();' initiates the creation of the iframe.
I have the following JS function that is fired when a image is clicked. This opens the sketcher in an iframe:
function clickOnImage(pict) {
currentPict = pict;
var oWnd = $find("modalWindowEditStructure");
oWnd.show();
oWnd.get_contentFrame().id = "sketchImg";
------------------- EXECUTED LAST -------------------------
MarvinJSUtil.getEditor("#sketchImg").then(function (sketcherInstance) {
marvinSketcherInstance = sketcherInstance;
}, function () {
alert("Cannot retrieve sketcher instance..!");
});
------------------- EXECUTED LAST -------------------------
if (lastmol && marvinSketcherInstance) {
//Import mol
marvinSketcherInstance.importStructure("mol", lastMol).catch(function (error) {
alert(error + ".. that was the error!");
});
}
else {
alert("Sketcher not available..!");
}
}
The problem here is as follows:
The code marked above and starting with: 'MarvinJSUtil.getEditor' is excecuted AFTER the code below where I need to use the sketcher instance!
Because of that the sketcher is not available when needed.