Marvin Javascript offscreen initialization

User 873a9ae9d0

31-01-2014 10:30:06

HI,


 


I am wondering if it is possible to 'off screen' initialize Marvin for Javascript.


This is the scenario:


I have a multipage asp.net app. One of the pageviews contains the Marvin for Javascript iframe tag.


The start page of the app does NOT contain any Marvin for Javascript iframe tag.


When the app starts and I navigate to the pageview with the Marvin for Javascript iframe tag, the editor


is visible BUT seems to be not initialized correctly, since I can not draw any structure.


When I do a POSTBACK on the pageview that contains the iframe tag M4J , I can afterwards draw structures.


Of course I want to AVOID to perform that postback !


Question: Is there a way to initialize Marvin for Javascript in a multipage app and not having the Marvin for Javascript iframe on the startpage the page ?


Hope one can help.


Regards


Hans-Juergen


AKos GmbH

ChemAxon 6c76bc6409

31-01-2014 10:50:04

Moved your question to the correct - Marvin Javascript - board.


Andras

ChemAxon 996dedebe0

04-02-2014 14:43:47

Hello hansh,


 


Hidden initialization is not possible with Marvin for Javascript, because the application needs information about it's offscreen size. I suggest you to use a lazy init for the editor, so create the first instance at the first time you need it to appear, in an already visible iframe.


 


i hope i could help you.


 


Regards,


 


Janos Papdeak

User 873a9ae9d0

04-02-2014 19:21:54

HI Janos,


 


thanks for the reply.


Can you provide a (javascript) code snippet of how I can initialize the M4J sketcher ?


As mentioned in the original post- The initialization should NOT require an additional postback.


Hope to hear from you.


best regards


Hans-Juergen

ChemAxon 996dedebe0

04-02-2014 20:50:59

Dear Hans-Juergen,


in this example, please see the getMarvinPromise method. The example uses jQuery, but as you can see, the appropriate functions can be replaced.


https://marvin4js.chemaxon.com/marvin4js-latest/examples/example-edit-images.html


If this solution won't work for you - or if i misunderstood something, please reply here or send us an email to marvin4js-support _at_ chemaxon.com , and i will discuss your problem with my collegues.


 


Best Regards,


 


János