新手问题 semantic-ui 的 javascript 不工作

VincentJiang · March 21, 2014 · Last by jxs471494539 replied at March 21, 2014 · 3825 hits

今天在配置 semantic-ui-sass with Rails,链接如下: https://github.com/doabit/semantic-ui-sass#semantic-ui-sass-with-rails 按照方法配置网站的 CSS 可以工作,但 Javascript 就不工作,请问有无高手可以为我解答? 以下是我 application.js 配置后的内容:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
// Loads all Semantic javascripts
//= require semantic-ui
//= require_tree .

谢谢!

页面源代码里面 semantic-ui 的 js 文件有没有? 如果有,那检查你的代码是不是写正确,光引用了 js 文件是不会工作的,比如要这样:

$('.ui.checkbox').checkbox();
$('.ui.dropdown').dropdown();

相应的功能才有

#1 楼 @miclle 感谢,按照你的方法已经解决问题!之前用惯了 Bootstrap,以为直接就就有效果的

You need to Sign in before reply, if you don't have an account, please Sign up first.