2013-02-17 63 views
0

我怎麼做,所以當我做這個調用來電調用javascript函數?

client.notification("test", "test", function(){ 
     alert("Hello world"); 
}); 

我可以調用函數(裏面的東西){....}在「client.notification」?

ex。

var client = ({"notification" : function(a,b,c){ 
    document.write(a + b); 
    if (....) { 
     //call the alert stuff from the function "c" 
    } 
}); 

我已經試過這樣:

$('#notification').click(eval(c)); 

沒有運氣

+0

就像任何其他的功能。 'c()' – JJJ 2013-02-17 09:42:02

+0

謝謝,發貼爲答案。 – 2013-02-17 09:45:28

回答

0

試試這個:

var client = ({"notification" : function(a,b,c){ 
    alert('inside of notification'); 
    c.call(); // or even `c()` 
}}); 

client.notification("test", "test", function(){ 
    alert("inside of callback"); 
});