473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I need assistance using callback


Hi All
please help me using callback .
my expected results are , alert ('1,2,3)
but the results are alert(undefine)

can anyone expain me why? thanks
function ActivateFuncOnObjects(list,Callbackfunction)
{
return function() { Callbackfunction.apply(list); };
}

function AlertF(text)
{
alert(text);
}

==============================================
var fn = ActivateFuncOnObjects2('1,2,3',AlertF);
fn();
Oct 23 '08 #1
2 1131
Montezuma's Daughter meinte:
Hi All
please help me using callback .
my expected results are , alert ('1,2,3)
but the results are alert(undefine)

can anyone expain me why? thanks
function ActivateFuncOnObjects(list,Callbackfunction)
{
return function() { Callbackfunction.apply(list); };
}
Apply expects a reference to "this" as the first parameter [1].
Callbackfunction.apply(null, list) should work.
Gregor

[1]
<https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/apply>
Oct 23 '08 #2
On 2008-10-23 14:26, Montezuma's Daughter wrote:
my expected results are , alert ('1,2,3)
but the results are alert(undefine)
function ActivateFuncOnObjects(list,Callbackfunction)
{
return function() { Callbackfunction.apply(list); };
You don't need apply() here, just write Callbackfunction(list). If this
is a reduced example, and you do need to use apply() for some reason,
you'll have to call it with the correct arguments. The first argument is
an object to be used as 'this' in Callbackfunction, and the second
argument is an array.

https://developer.mozilla.org/en/Cor...Function/apply
- Conrad
Oct 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Felix Kater | last post by:
Hi, in a given library I register callback functions with this function: bool set_callback(int index, int (*callback_function)(long)); I need the callback function to also pass the index...
3
by: Jim | last post by:
I have a windows application that is accessing unmanaged code and providing a callback function that will create events at unknown time spans. When the EventHandler (callback function) fires it...
1
by: Sean | last post by:
Im fairly new to C# and am having a few problems getting events to fire when using COM interop with C#, can someone take a quick look at the following example and give me a pointer as to why the...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
4
by: NWx | last post by:
Hi, I' trying to implement a callback method when a cache object expires I want to do this to automatically logout user after a timeout (for demo purposes) My thought is, when user logon,...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
3
by: Paul | last post by:
I have been trying to code a callback in vb.net using the delegate method. I have successfully compiled the program and run it but after it accessess the copyfileex winapi method and then calls the...
22
by: SQACSharp | last post by:
I'm trying to get the control name of an editbox in another window. The following code set the value "MyPassword" in the password EditBox but it fail to return the control name of the EditBox. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.