Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- From: "Bonzo" <tempuser@xxxxxxxxxxxxxx>
- Date: 21 Nov 2005 11:02:54 -0800
Duncan & Michael,
Thanks for the input... I will definitely check this option out...
I understand your concern over the design Michael, it is a rather
strange one (my design that is)
It evolves from the desire to build elements via the DOM, then add
eventHandlers to them. (This has already been done, and works like
magic in all browsers except IE)
In Moz, and Opera, I can use:
someElement.setAttribute('onclick', 'funcB(event, ' + param1 + ', ' +
param2 + ');');
This will create the attribute, register the event, and all is well...
of course, IE will fail horribly... it will set the attribute, but not
register the event.
So, option2, was to call addEventListener/attachEvent, to add the event
handling... the only problem being, that I can't pass params (which,
argue as one might, I simply need for the "magic" I'm cultivating...
read: "seriously dynamically dynamic HTML")
So, I hacked** together something, that will wrap the "event
registration" call, to register the events in Moz, Opera, IE, etc.
A-N-D, allow me to pass parameters!...
**In the hack, I want to pass the event (default first argument in Moz,
Opera, etc.) to my handler, BUT, also (for simplicity), also pass it
along to IE (cause it is plain anoying to have to retrieve it inside
every single event handler on my page, if I can pass it instead)
***(there is actually more, but I'm trying to simplify here)
Long Story short, I have the event, and I have the parameters, and thus
I want to call the event handling function, with the event, and all
arguments passed to my "event handler wrapper"... on to my actual event
handler...
</end-scary-js-idea>
Alternatively, I've been told I might have some luck, iterating over
the arguments, and building up a "function string" that I can eval()
when complete... I'm not sure if this will solve my problem either, but
it seems the "hackiest" of the ideas I've seen thus far.
PS for anyone that is thinking it, no, I can't just stuff in
foo.innerHTML = ''; Although this will work in IE, it is not where I
want, nor care to go.
Cheers,
Bonzo
.
- Follow-Ups:
- References:
- FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- From: Bonzo
- Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- From: Duncan Booth
- Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- From: Michael Winter
- FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- Prev by Date: Re: AJAX without XML
- Next by Date: Re: AJAX without XML
- Previous by thread: Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- Next by thread: Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
- Index(es):
Relevant Pages
|