[v] 如何在 Rails 中使用 jQuery UI?

在介紹 jquery-ui-rails 前,我們先來了解什麼是 jQuery UI, 以及它能做到什麼。最簡單的理解方式其實是點進去下方連結,點選左側欄位自己試試看:

https://jqueryui.com/

而 jquery-ui-rails 就是一個讓 rails 能跑 jquery ui 的 gem

https://github.com/joliss/jquery-ui-rails

Gemfile

gem 'jquery-ui-rails'

Require Everything

application.css

/*
 *= require jquery-ui
 */

application.js

//= require jquery-ui

Require Specific Modules

The jQuery UI code weighs 51KB (minified + gzipped) and takes a while to execute, so for production apps it's recommended to only include the modules that your application actually uses. Dependencies are automatically resolved. Simply pick one or more modules from the asset list below.

application.css

/*
 *= require jquery-ui
 */

application.js

//= require jquery-ui