29
32

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

railsでのjsプラグインの使い方

Posted at

自分用めもめも。

javascriptプラグインはどこにおくの?

1.ファイル自体の置き場所

app/assets ・・・独自のファイル
lib/assets ・・・アプリケーション外で共通のもの 
vendor/assets ・・・ プラグインとか ←ココ!

vendor
|
|----/assets
  |
  |---- /javascripts
    |
    |---- /tablesorter  ←こんなかんじ??

2.ファイルの読み込みの設定

application.js
//= require_tree ../../../vendor/assets/javascripts/.

//= require_directory .

上の1文を追加。
もちろん、require_directoryとかrequire_treeの前に呼んでおかないと、プラグインの適用ができない(><)
cssも同じ!

application.css
*= require_tree ../../../vendor/assets/stylesheets/.

tablesorterを使ってみよう!

まずは__jquery.tablesorterをダウンロードしてそこからjsファイルとthemaディレクトリのblue/greenを取ってくる。

1  $(function(){
2	    $(document).ready(function()
3	        {
4	            $("table#analysis").tablesorter();
5	        }
6	    );
7	})

<table id="analysis" class="tablesorter">

この2つは必須。
あとはcssのstyle.cssでうまく表示を変更してあげて下さい。

29
32
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
32

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?