jquery.delegate() 和 Coffeescript
我是 Coffeescript 的新手,想使用 jquery 1.6.4 中的 delegate() 方法。方法签名为.delegate(selector, eventType, handler)
。我该如何在 Coffeescript 中调用这个方法?我正在使用 Rails 3.1。
谢谢, 丹妮.
I am a newbie in Coffeescript and would like to use the delegate() method in jquery 1.6.4. The method signature is .delegate( selector, eventType, handler )
. How do I go about calling this method in Coffeescript? I am using Rails 3.1.
Thanks,
Dany.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
就像咖啡脚本中的其他方法一样?
我觉得我对你的问题漏掉了一些东西......
just like any other method in coffeescript?
i feel like i'm missing something about your question...
要回答您的 2 个处理程序问题:
http://js2coffee.org/ 是一个很好的后台网站,如果您编写coffescript,无需自动编译器,允许您立即检查生成的javascript。
To reply to your 2 handlers question:
http://js2coffee.org/ is a good website to have in background if you write coffeescript without an automatic compiler that allows you to check imediatly the resulting javascript.
这纯粹是美学问题,但我更喜欢将处理程序包装在命名函数中(如果有多个函数):
对我来说,它看起来更干净。
It's a pure matter of aesthetics, but I prefer to wrap my handlers in named functions (if there's more than one):
It just seems cleaner for me.
我可能很笨,但上面的正确答案花了我一些时间才弄清楚。
第一个参数是 div 或 ?您想要监视新元素,那么您需要提供元素标识符,然后提供事件类型
I may be dense but the correct answer above took me some time to figure out.
the first parameter is the div or ? that you want to watch for new elements, then you need to provide the element identifier , then the event type