-
December 18th, 2006, 07:41 AM
#1
Delegate in javascript
hello,
I would like to know if it is possible to use delegate in javascript and if so how to do it.
(I want to send to a function a pointer to other function and raise that pointer).
-
December 18th, 2006, 09:24 AM
#2
Re: Delegate in javascript
What do you mean by delegate? I assume you are talking about a functionality of another programming language. Could you please explain more?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 18th, 2006, 10:16 AM
#3
Re: Delegate in javascript
In C# for example I can declare a delegate and pass to it a function from a different class and in the class where I declared the delegate I can raise an event and activate that function. I would like to know if it is possible to do it in javascript.
-
December 18th, 2006, 10:19 AM
#4
Re: Delegate in javascript
To a person who knows C#, that is clear but to a person who knows scripting, that is not. Can you give a code example maybe?
Is a delegate a variable? What do you mean "raise" an event?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 18th, 2006, 10:30 AM
#5
Re: Delegate in javascript
First I want to apologize if I insulted you. In my code a draw a table and inside one of it’s row I draw an input. Because I draw this table for different purpose I need to connect the onfocusout event to different functions (each time to one function) and I need to be able to activate that function when the input loses focus.
-
December 18th, 2006, 10:36 AM
#6
Re: Delegate in javascript
No. There was no insult. Okay, I think I understand what you are saying.
In the <input> tag, you can add an event called onblur. This will occur when the object loses focus. Just add the function there.
Code:
<input type="text" name="blah" onblur="function(variable if any)">
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 19th, 2006, 03:23 AM
#7
Re: Delegate in javascript
my problem is that i need to add the function dynamically. I need to do:
getElementById('string').onblur = function(parameters).
when the function is different each time.
-
December 19th, 2006, 08:36 AM
#8
Re: Delegate in javascript
So do it that way.
Code:
document.getElementById('OBJECT ID').onblur = function(){
// do what you want here...
}
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|