Hi,
I'm using the JDraw API in my Pipeline Pilot protocol to allow drawing of structures in the front end. My protocol has a JDraw component (with an html 'id' attribute set to 'jd') and a button ("Clear Sketcher") with an onclick event handler on the button that calls a javascript function: clearMol('jd') to clear the JDraw sketcher using the clearMolecule() method (mentioned in the JDraw API). My javascript code is as follows:
function clearMol(jdID) {
try {
// The JDraw sketcher has ID set as 'jd' which is passed to this function as jdID and we use it to select it below.
var jdbox= document.getElementById(jDrawID);
if (jdbox != null) {
// Note: The error occurs at the following line of code. Apparently the JDraw sketcher does not recognize this method which is a part of the JDraw API.
jdbox.clearMolecule();
}
}
catch(err) {
window.alert("Error Message: "+ err.message);
}
}
The code above, when executed, shows this error message: "Object does not support property or method 'clearMolecule()'."
I'm unable to figure out why I'm getting this error when the method that I'm using: clearMolecule() is a valid method documented in the JDraw API docs. The approach used by me, i.e., retrieving the JDraw sketcher using its ID is one that I've seen in examples on this forum and also on the JDraw page on the Accelrys website: http://accelrys.com/products/informatics/cheminformatics/draw/jdraw-demo.html
If anyone has any suggestions on what might be causing this error and how should the JDraw sketcher be retrieved and cleared, please let me know.
Thanks.