Great, so if that is all you are doing, there is no need for the XHTML
business. Really that's there just because it was in Jmol 11, and actually
it was almost never used. XHTML was just too too difficult all around.
HTML5 is way better.

So what you would do to populate a div in the jQuery way is simply this, as
used in supersimple.htm:

$(document).ready(function() {

Info = {
    width: 400,
    height: 400,
    debug: false,
    color: "0xC0C0C0",
  disableJ2SLoadMonitor: true,
  disableInitialConsole: true,
    addSelectionOptions: true,
    serverURL: "your server...../jsmol/php/jsmol.php",
    use: "HTML5",
    readyFunction: null,
    script: "load $caffeine"
}

$("#mydiv").html(Jmol.getAppletHtml("jmolApplet0",Info))

});

That's it. It's really that simple. jQuery and JSmol take care of
everything else for you.

Info.serverURL will only be necessary if you are delivering binary files or
if you are allowing users to save images and states.

I think perhaps you were still using the old Jmol2.js, and unless you have
hundreds of pages that were extant back before JSmol arrived, you should
get rid of that dependency. Life will be easier.

... more in another more general thread...

Bob


On Sat, Feb 8, 2014 at 4:11 PM, Charles Harrison Shubert
<[email protected]>wrote:

>  Thanks, Bob!  I'll download the latest build this weekend.
>
>  My app calls several initialization functions and init_jsmol is one of
> them. I initialize my UI (view), the state of my app (controller and
> model), then I initialize jsmol. I want to use the callbacks to populate
> the model. The model.is.is_jsmol is the id of the div where I want Jmol
> to render the image. It certainly seems reasonable in hindsight to look at
> an example called images.htm. Wish I'd thought of that.
>
>  --Chuck
>
>  On Feb 8, 2014, at 1:40 PM, Robert Hanson <[email protected]> wrote:
>
>       Jmol.setXHTML = function(id)
>
>  is almost never used and hasn't been tested much. This is an HTML5 app,
> not XHTML.
>
> What is calling init_jsmol(state), and when?
>
>  With jQuery now, it's much  easier. Check some of the examples in
> jsmol.zip.
>
> http://chemapps.stolaf.edu/jmol/jsmol/images.htm
>
>  is a good example that uses jQuery for the applet construction and also
> uses callbacks.
>
>
>
>
> On Fri, Feb 7, 2014 at 1:38 PM, Charles Harrison Shubert <[email protected]
> > wrote:
>
>> Hi,
>>
>>  I'm clearly not reading the documentation correctly and I'm missing
>> something.  I want to use the JSmol callback functionality. What am I doing
>> wrong?
>>
>>  Thanks,
>>
>>  --Chuck
>>
>>  My javascript:
>>
>>      function init_jsmol(state) {
>>
>>              // ... other initialization
>>
>>              Jmol.setXHTML(model.ids.id_jsmol);
>>
>>              var Info = {};
>>             Info.script = session.modelControl.getActiveScript(state);
>>             Info.j2sPath = model.jsmol.j2sPath;
>>             Info.disableInitialConsole = true;
>>             Info.disableJ2SLoadMonitor = true;
>>
>>              jmolObject = Jmol.getApplet(model.ids.id_jsmol, Info);
>>
>>              // ... other initialization
>>     }
>>
>>      function myMessageCallback(one, two) {
>>         console.info("I'm in myMessageCallback: " + one);
>>         console.info("I'm in myMessageCallback: " + two);
>>     }
>>
>>      function getJSmolInfo(state) {  // called from another part of my
>> code.
>>         try  {
>>             console.info("getJSmolInfo entry");
>>
>>              script(";set messageCallback 'myMessageCallback';");
>>             script(";define chucksel '[ALA]1:A.O or [ALA]1:A.C'; select
>> chucksel; color atoms pink;");
>>             script("message 'hi ho';");
>>
>>              console.info("getJSmolInfo exit");
>>             return Jmol.getPropertyAsArray(jmolObject, "orientationInfo");
>>         } catch (err) {
>>             console.info("ERR getJSmolOrientationInfo xxx");
>>             console.info(err);
>>         }
>>         return null;
>>     }
>>
>>      function script(script) {
>>         try  {
>>             jmolObject._script(script);
>>         } catch (err) {
>>             console.info("ERR scriptWait");
>>             console.info(err);
>>         }
>>     }
>>
>>  What I see:  the Alanine that I loaded has the A.O and A.C colored
>> pink.  I also see the "orientationInfo" when I look at the return from
>> getJSmolInfo.  The "state" argument to getJSmolInfo is for later use.
>>
>>  What I didn't see: "hi ho" in the console or any evidence that
>> myMessageCallback is called.
>>
>>  Chrome Console:
>>
>>   getJSmolInfo entry 
>> jsmolControl.js:89<http://localhost:8002/StarBiochem/sb_controller/jsmolControl.js>
>>  getJSmolInfo exit 
>> jsmolControl.js:93<http://localhost:8002/StarBiochem/sb_controller/jsmolControl.js>
>>  exec _jsmol loadClazz null -- OK VM592:250
>>  exec _jsmol start applet null -- OK VM592:250
>>  event.returnValue is deprecated. Please use the standard
>> event.preventDefault() instead. VM592:110
>>
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Jmol-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>>
>
>
> --
> Robert M. Hanson
> Larson-Anderson Professor of Chemistry
> St. Olaf College
> Northfield, MN
> http://www.stolaf.edu/people/hansonr
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk_______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>


-- 
Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to