Help us understand the problem. What is going on with this article?

Slimのテンプレートにjavascriptを組み込む

More than 5 years have passed since last update.
sample.slim
doctype html
html
   head
      script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"
      script src="js/animatedtablesorter/tsort.min.js"
      link rel="stylesheet" href="js/animatedtablesorter/style.css" type="text/css"
   body
      javascript:
        $(document).ready(function(){$('table.tableSorter').tableSort();});

      table border=1 class="tableSorter"
        tr
          th ID
          th Thumnail
以下略

scriptへのリンク自体はimgを埋め込む時と同じ感じ。
scriptを直接記入する時はjavascript:の下の行にインデントつけて記述する。

今回はjquery-animated-table-sorterを組み込んでみた。

sinatraでは静的なファイルはpublicディレクトリに格納する。
従ってスクリプトは以下のような配置となる。

├── public
│   └── js
│       └── animatedtablesorter
│           ├── arrow_asc.png
│           ├── arrow_desc.png
│           ├── style.css
│           ├── tsort.js
│           └── tsort.min.js
├── views
│   └── index.slim
│   └── slideshow_list.slim

script src="js/animatedtablesorter/tsort.min.js"
と記載しているようにURL自体にはpublicのディレクトリ名は記入しない。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした