【发布时间】:2014-07-17 20:23:54
【问题描述】:
这是我的看法:
<a href="#" onclick="delete_quote(this);" class="quote-delete">
<i class="fi-x small-1"></i>
</a>
这是我的咖啡脚本文件:
$(document).ready ->
$('a.quote-delete').hide()
$('div.quote').mouseenter ->
$(this).children('a.quote-delete').show()
$('div.quote').mouseleave ->
$(this).children('a.quote-delete').hide()
delete_quote = (element) ->
alert 'hi'
$(document).ready 部分工作正常,但是当我按下链接时,我没有收到“两个”消息,并且在浏览器控制台中出现错误:
Uncaught ReferenceError: delete_quote is not defined
这里是编译好的JS文件:
(function() {
var delete_quote;
$(document).ready(function() {
$('a.quote-delete').hide();
$('div.quote').mouseenter(function() {
return $(this).children('a.quote-delete').show();
});
return $('div.quote').mouseleave(function() {
return $(this).children('a.quote-delete').hide();
});
});
delete_quote = function(element) {
return alert('hi');
};
}).call(this);
【问题讨论】:
标签: javascript ruby-on-rails coffeescript