Hi all,
I am using some components from a JS library (scriptalicious), where
callback functions are arguments to the constructors of the components
like so:
someClass x (name)
{
this.name = name;
this.slider = new
Control.Slider(this.name+'slide',this.name+'track' ,{
onSlide:function(v){foo()},
onChange:function(v){bar(v)}
);
}
Since I would like to dynamicaly create these components at runtime, I
would like the engine (the browser) to evaluate the value of a member
variable (this.name) and to pass this to the callback of the event,
like
.... onChange:function(v){bar(this.name)} ...
Is this possible by some escaping mechanism or so? (and am I making
myself clear enough?)?
Thanks a lot in advance 2 2302
Tyler wrote: Hi all,
I am using some components from a JS library (scriptalicious), where callback functions are arguments to the constructors of the components like so:
someClass x (name) { this.name = name; this.slider = new Control.Slider(this.name+'slide',this.name+'track' ,{ onSlide:function(v){foo()}, onChange:function(v){bar(v)} ); } Since I would like to dynamicaly create these components at runtime, I would like the engine (the browser) to evaluate the value of a member variable (this.name) and to pass this to the callback of the event, like .... onChange:function(v){bar(this.name)} ... Is this possible by some escaping mechanism or so? (and am I making myself clear enough?)?
If you bind the information you will to provide to the callcack function
to the element with the callback, you can access it through the event.
Something like
element.info = {name:this.name};
element.onChange = callback;
function callback( event )
{
// x-browser code to get the event.
var info = event.target.info;
};
--
Ian Collins.
Hi Ian,
thank you for the very handy tip, this is a nice one!
(I have solved my problem differently in the meantime by sending a
backpointer to the calling class instance to the callback, which was
an inbuild option in the nice scriptalicious slider)
But anyhow, this is an interesting method,
Thank you for your suggestion
Cheers This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sinisam |
last post by:
Object oriented programming is not a new term to me, but when I tried
to do some of it... uhh... it sure looked (and felt) like Hell :) I
won't bother about things like "help me learn it" (but...
|
by: Xah Lee |
last post by:
What are OOP's Jargons and Complexities
Xah Lee, 20050128
The Rise of Classes, Methods, Objects
In computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...)...
|
by: Joel |
last post by:
Hi all,
Forgive me if I've expressed the subject line ill.
What I'm trying to do is to call a c++ function given the following:
a. A function name. This would be used to fetch a list of...
|
by: Leslaw Bieniasz |
last post by:
Cracow, 20.10.2004
Hello,
As far as I understand, the generic programming basically consists
in using templates for achieving a static polymorphism of the
various code fragments, and their...
|
by: Prashanth Ellina |
last post by:
Hi,
I have a feeling that OOP can be done in C also. I have used a
structure to hold member variables and function pointers. The
structure is used as a class to create new 'objects'. But I hit a...
|
by: Manuel |
last post by:
Please, excuse me for starting this discussion.
I'm not a troll, and I love the OOP architecture.
However I'm a C++ newbie, and sometimes it's hard for me to fully
understand the improvement of...
|
by: Mary Pegg |
last post by:
No point re-inventing the wheel, so thought I'd see if
anybody's got some good example code kicking around.
(Please excuse trivial syntactical errors, it's all coming
off the top of my head).
...
|
by: Chris Carlen |
last post by:
Hi:
From what I've read of OOP, I don't get it. I have also found some
articles profoundly critical of OOP. I tend to relate to these articles.
However, those articles were no more objective...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |