Radek
Radek

Reputation: 11121

how to provide jQuery support in Sinatra?

I have very simple sinatra application up and running. Now I want to use jsTree (jQuery plugin) in my sinatra application.

I do not know how I provide the jQuery support in sinatra. Where I put the files and then how would the <script src="/path/to/jstree.js"></script> look like?

Upvotes: 0

Views: 4347

Answers (2)

Yorkshireman
Yorkshireman

Reputation: 2343

The quickest solution is to simply paste the CDN into your view file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">

    <title></title>

    <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
  </head>

  <body>
  </body>
</html>

As per: https://jquery.com/download/#using-jquery-with-a-cdn

This is what I did and it worked no problem with my Sinatra app.

Upvotes: 0

Blender
Blender

Reputation: 298374

This looks relevant: https://github.com/ezgraphs/jquery-sinatra-demo.

It seems as if you need to create a /public/ folder and put jQuery into there. And from your index.html file, just reference it as if it resided in the same directory as the index.html file:

<script type="text/javascript" src="jquery-latest.js"></script>

Upvotes: 4

Related Questions