PDA

View Full Version : how can i pass extra data to "Message.confim()"



sanghk
19 Apr 2007, 1:41 AM
//A function code:

function myfun( param1, param2 ){
MessageBox.confirm("title","Are you sure?" ,function(btn){
//do something
alert(param1);

} );
}

//how can i get the param1 ?

Illiarian
19 Apr 2007, 3:15 AM
Well, you've already gotten it:


function myfun( param1, param2 ){
MessageBox.confirm(
"title",
"Are you sure?",
function(btn){
//do something
alert(param1);
alert(param2);
}
);
}


The third param that you pass here is a closure - a function that maintains it's state and context and environment. So when it runs it displays the params that you passed to myfun.

sanghk
19 Apr 2007, 4:46 AM
When i call : myfun("hello" , "world") ;
Display a confirm Box ,after i press "Yes" button , then display "undefine" 。
How can i pass param1 , param2 to callback ?

sanghk
19 Apr 2007, 4:52 AM
I pass error param ;
thank Illiarian !