$ is not defined

I’m trying to get jquery to work but no matter what I try I still get the following error message:

$ is not defined

I’ve tried to place the following line at the beginning of all.js:

//= require plugins/jquery1.11.2.min

As well as trying out the jquery-middleman gem, but to no avail.

Is there a proper way to use jquery with Middleman?

I’m using HAML for my markup, and just have the following line a layout file:

= javascript_include_tag ‘//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js’, ‘all’

Might not have the cool factor that the gem has, but it works for me.

Did you try

//= require „_jquery.min"

In config.rb your javascript directory is probably

config[:js_dir] = 'plugins'

I solved this problem by doing the following.

Gemfile:

gem 'middleman-sprockets', '4.0.0'
...
source 'https://rails-assets.org' do
  gem 'rails-assets-bootstrap', '1.0.0'
  gem 'rails-assets-jquery', '2.1.1'
end

javascripts/all.js

//= require jquery
//= require bootstrap
...