I'm getting to know the JS API, primarily using examples to seek patterns to follow. In many cases, it appears that I can perform the same function in JS code as XML. For instance, in the UIConfig example, it's demonstrated that toolbars can be constructed in either manner:


<mxDefaultToolbar as="toolbar">
        <add as="MyFirstAction" action="myFirstAction" icon="images/icons48/gear.png"/>
        <add as="Gear" template="myFirstTemplate" style="rounded=1" icon="images/icons48/server.png"/>
        <add as="Earth" template="myFirstTemplate" style="shape=ellipse" icon="images/icons48/earth.png"/>


    // Creates the second toolbar programmatically
    var container = document.getElementById('toolbar');
    var toolbar = new mxDefaultToolbar(container, editor);
    //Use eg. mxResources.get("delete") to translate tooltip
    toolbar.addItem("Show XML", "images/icons48/gear.png", "myFirstAction");
    toolbar.addItem("Delete", "images/icons48/keys.png", "delete");

I'd really like to handle everything in JS if possible. Is there anything that can only be done in XML?

In a similar vein, are there any examples that use no XML config?

asked 04 May '12, 15:06

peteorpeter's gravatar image

accept rate: 0%

Everything can be done without XML. There are several examples using mxEditor without a config (eg. dbeditor.html, ports.html, schema.html, swimlanes.html and validation.html).


answered 05 May '12, 02:56

Gaudenz's gravatar image

accept rate: 39%

Thanks for the references!

(07 May '12, 14:13) peteorpeter
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 04 May '12, 15:06

Seen: 1,362 times

Last updated: 07 May '12, 14:13