cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Callback after an attribute is modified

pchateil
1-Newbie

Callback after an attribute is modified

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 3

You can do this with an attribute rule, or <att> in an Arbortext FOSI. See help 22.

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



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

Top Tags