Skip to main content
7-Bedrock
February 7, 2012
Question

Callback after an attribute is modified

  • February 7, 2012
  • 3 replies
  • 892 views
Hi all.

I need to use an attribute value to trigger an action.
In ACL, the modify_tag callback is called before a "Modify Attributes"
dialog box is opened.
What I need is to call a function after an attribute is modified.

Any thoughts?

Thanks.

Pierre Chateil
LCI TechPub Sud-ouest
France

    3 replies

    1-Visitor
    February 7, 2012
    You can do this with an attribute rule, or <att> in an Arbortext FOSI. See help 22.
    18-Opal
    February 7, 2012
    Hi Pierre--

    I'm not sure how you'd do that in ACL, but it's not very hard in AOM, if
    you are comfortable with Java or JavaScript. You can attach an event
    listener to the document object that listens for DOMAttrModified events,
    and (after checking the element and attribute names) does whatever you
    need done.

    It would be something like this, in an editinit file (using the default
    Rhino JavaScript flavor):

    // *** untested code, debugging is left as a exercise ***
    function attrEvent(event)
    {
    var node = event.target;
    var attrname = event.relatedNode.nodeName;
    if ((node.nodeName == "{target-node}") && (attrname ==
    "{target-attr}")) {
    Application.alert("Hey! You modified an " + attrname + " attribute
    on a " + node.nodeName + " element!");
    event.stopPropagation();
    }
    }

    var doc = Application.activeDocument;
    // define an object with the required handleEvent method
    var o = { handleEvent: attrEvent };
    var listener = Packages.org.w3c.dom.events.EventListener(o);
    doc.addEventListener("DOMAttrModified", listener, true);


    HTH.

    --Clay

    Clay Helberg
    Senior Consultant
    TerraXML
    1-Visitor
    February 8, 2012


    John Sillari
    Chief Technologist
    Technical Services Division
    Dayton T. Brown, Inc.