Code:
function remove_comment(){
var id = "bla";
Msg().prompt( "blabla" , function(){ Ajax().post( "id=" + id ) } , id );
}
Msg().prompt( txt , fn , args ){
$( elem ).click( fn );
}
As you can notice, I need to pass this function to prompt(), while inside the passed function one of the arguments depends on the variable id
.
Now, after the function passed I need it to be assigned to an element's onclick event (the code abode is not using jQuery).
First, I'd tried to do this:
$( elem ).click( fn.apply( this , id ) );
,
$( elem ).click( fn.call( id ) );
, but these codes execute the function immediately (I already know why, no need to explain).
Then I'd tried to play with the function and arrange it as string to pass directly as onclick='THE_FUNCTION'
html code to the element, but with no success.
No comments:
Post a Comment