在 Rails 应用程序上工作,我的咖啡脚本代码已损坏。这
$('.post-reply4').hide()
正在工作,但没有别的。单击 message4 链接不会执行任何操作。
控制台给出了这个错误: Uncaught TypeError: object is not a function
咖啡稿:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery ->
toggleThis = () ->
$('#post-reply4').show()
$('.post-reply4').hide()
$('#message4').on('click') ->
toggleThis
html:
<a href="#message" id="message4">reply</a>
<div class="post-reply4">
stuff
</div>
应用程序.js:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .