Assuming and dcr-type XML template and not a DCR based template. If DCR based, remove /cnt from.[PHP]IWEventRegistry.addItemHandler("/cnt/aaa/bbb","onReplicantAdded", alertMe);function alertMe(item){ alert("hello");} [/PHP]
var auto_mode = false;function init() { //... assume onReplicantAdded handler added here}function onRepAdded(item) { //... if (auto_mode) { //... code to be run only if addInstance called from another function } else { //... code to be run only if the user clicked the '+' button } //... auto_mode = false; // reset to default state}function someOtherFunc() { //... auto_mode = true; myItem.addInstance(1); //...}
First - I believe you meant to say "iwov" style DCT (as compared to "xml" style DCT) - and not "DCR based"Second - if you re-read the original posting - I believe you'll find that the question wasn't about how to put an item handler on an item for onReplicantAdded, but how to distinguish whether the item handler was invoked by a user clicking on the '+' button or programmatically via an addInstance() call.To answer what I believe the intent of the question was - no - I don't think there is any way to distinguish the two directly - however you might be able to play around with some global javascript variables, as in this simplistic example:var auto_mode = false;function init() { //... assume onReplicantAdded handler added here}function onRepAdded(item) { //... if (auto_mode) { //... code to be run only if addInstance called from another function } else { //... code to be run only if the user clicked the '+' button } //... auto_mode = false; // reset to default state}function someOtherFunc() { //... auto_mode = true; myItem.addInstance(1); //...}