【发布时间】:2014-11-21 17:13:37
【问题描述】:
我有这个小提琴:http://jsfiddle.net/jj258ykp/2/
对于 BTN2 和 BTN3,我在单击时看到警报,我在 BTN1 上看不到警报,我想看到它。
这是咖啡脚本:
class A
method: ->
alert "method"
method2: ->
alert "method2"
@method3: ->
alert "method3"
setup: ->
$('button#btn').click( (event) ->
@method()
)
$('button#btn3').click( (event) ->
A.method3()
)
$ ->
a = new A
a.setup()
$('button#btn2').click( (event) ->
a.method2()
)
这是我的 HTML:
<button id = "btn">BTN1</button>
<button id = "btn2">BTN2</button>
<button id = "btn3">BTN3</button>
【问题讨论】:
标签: javascript jquery events coffeescript