Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
formapi Event Handler
jamesk
Hi,
Ive been trying to use the formapi event handlers but have had a couple of problems:-
1) I cant pass a parameter to the function!
It works without any parameters...
e.g. IWEventRegistry.addItemHandler("/test", "onItemChange", myfunction);
but i want to do something like
IWEventRegistry.addItemHandler("/test", "onItemChange", myfunction("param1","param2"));
but it just seems to run the function before the event has even happened.
2) is there anyway i can use standard javascript events - such as 'onFocus'. I would like to have a select drop down box which populates when the user clicks on it. I find the documented events quite limited.
thanks
Find more posts tagged with
Comments
Migrateduser
Since no-one else has responded--
Sorry James, but the FormAPI event handlers have pre-defined function prototypes, they only accept specific arguments. Event handler functions are invoked directly from the event subsystem, so how would you pass the args anyway? ie, you don't call the event handlers--the browser does. How would you make it pass the variables?
Bad as it might be, I'll suggest storing the values you want to access in the event handlers into global vars, where your functions can read them.
As for your second point, I have no idea, but I think the answer is no at this time.
bw
Bob Walden [bob.walden@interwoven.com]
Interwoven Education Group
IM: Yahoo, MSN bob_walden
Ray
Hi
I don't have an answer for you as I have a similar problem, I don't understand why I cant pass arguments to my function ??
Piers
Ok I understand the limitations of the system, but I don't understand your solution, can you provide an example of the global vars etc.
If we can't pass variables, is there a way from the js script of identifying what element trigerred the function? eg. was it replicant 1, 2,3 or n.
Without knowing this it seems like I have to create multiple instances of the same function (just in case) to handle replicants which seems extremely daft. I really hope I'm missing something here.
Thank you.
martina
Hi Piers,
Here is a sample code on how you can access an element which called the function (you could place your addItemHandler into for loop for replicants):
IWEventRegistry.addItemHandler('/Keyword[1]','onCallout',test);
function test(item) {
alert(item.getName());
}
Best regards,
martina
Piers
Oh My ****.. THANK YOU THANK YOU THANK YOU THANK YOU
A life saver.... this is exactly what I needed
and as for replicants
Registry.addItemHandler('/Keyword','onCallout',test);
will add the handler for every Keyword replicant....
no looping
I owe you big time