Closed registerme1963 closed 3 years ago
The chem viewer (and other auto-launched widgets based on HTML tags) are created at the domReady
event handler of document. Therefore if Kekule.Widget.getWidgetById('chemDraw')
is called before that moment, no actual widget will be returned. To solve that, simply change those codes to:
Kekule.X.domReady(function(){
var chemViewer = Kekule.Widget.getWidgetById('chemDraw');
chemViewer.getRenderConfigs().getColorConfigs().setUseAtomSpecifiedColor(true);
});
It shows error 'Uncaught ReferenceError: Kekule is not defined' when kekule.js loaded before </body>
in the footer.
But works good when kekule.js loaded in the <head>.
Sorry a beginner in javascript
thanks
Usually the js scripts are loaded and parsed immediately at the place of Githubissues.
I'm trying to get the atom colours with chemwdget, but not succeeded. the following is my code
<script src="../../libs/kekule/kekule.js?modules=chemWidget,"></script>
<script> var chemViewer; chemViewer = Kekule.Widget.getWidgetById('chemDraw'); chemViewer.getRenderConfigs().getColorConfigs().setUseAtomSpecifiedColor(true);<script>
and them in the body I have a div element
<div id="chemDraw" style="width:100%;height:650px" data-widget="Kekule.ChemWidget.Viewer2D" data-chem-obj="url(#pyrrole)"></div>
I got an error 'Uncaught TypeError: Cannot read property 'getRenderConfigs' of undefined' I'm using the latest dist How do I correct it? thanks ps: can you please include in your chemwidget demos like atom colors, backgroundColors ?