2014-03-14 19 views
0

我想從toastr通知彈出點擊這些鏈接時,卻什麼也沒發生爲toastr通知調用jQuery函數

編輯:這裏是完整的代碼http://jsfiddle.net/XaVcR/的的jsfiddle我不知道如果我包括toastr正確雖然 成功 的.js

toastr.options.closeButton = true; 
toastr.options.positionClass = "toast-bottom-left"; 

$(document).ready(function() { 
    $('#success').click(notification('success', 'this was a success!')); 
}); 

function notification(type, message) { 
if(type == 'success') { 
    toastr.success(message,'<i>Success</i>'); 
} else if(type == 'error') { 
    toastr.error(message,'Error'); 
} else if(type == 'warning') { 
    toastr.warning(message,'Warning'); 
} else { 
    toastr.info(message,'Information'); 
} 
} 
+0

控制檯中是否有任何錯誤?你能顯示*整個*代碼嗎?或者在例如[的jsfiddle](http://jsfiddle.net/)? – Ashe

+0

http://jsfiddle.net/XaVcR/ – user3417966

回答

1

從問題:

$('#success').click(notification('success', 'this was a success!')); 

這應該是:

$('#success').click(function() { 
    notification('success', 'this was a success!'); 
}); 

您的jsfiddle有:

$('#success').click(function() { 
    notification('success', 'this was a success!')); 
}); 

,它與))在中間線的末端,是一個語法錯誤。

+0

它現在的作品,謝謝! – user3417966

+0

不客氣! – Ashe