【发布时间】:2019-12-03 21:45:02
【问题描述】:
我正在尝试让语义 UI 按钮在 Rails 6 中使用 Javascript 工作。但是,我的代码都没有正常工作。代码如下所示:
$(document).on('turbolinks:load', function() {
$('.message .close').on('click', function() {
$(this).closest('.message').transition('fade');
})
;
})
我得到的错误是:Uncaught ReferenceError: $ is not defined。
我的应用程序 JS 文件如下所示:
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
// Loads all Semantic javascripts
//= require jquery
//= require semantic-ui
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require_tree .
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
【问题讨论】:
标签: javascript jquery ruby-on-rails semantic-ui ruby-on-rails-6