我正在尝试在我的一个haml模板中插入内联j。
作为测试,我尝试了这个答案@ Include inline JS in HAML
.center_div.style1-form#new_post
%h3= t(:blog, scope: :backoffice)
= simple_form_for([:backoffice, :blog, @post], :method => :post, :html => { :class => 'form-vertical', :autocomplete => "off" }) do |f|
.style1-form-header
%h1= t(:new_post, scope: :backoffice)
.style1-form-body
= f.error_notification
= render "backoffice/blog/posts/form", :f => f
.form-actions
= link_to backoffice_blog_posts_path, :class => "btn btn-default" do
%i.glyphicon.glyphicon-th-list
%span= t(:list, scope: :application)
= f.button :submit, t(:register, scope: :application), :class => "btn btn-primary"
:javascript
$(document).ready( function() {
$('body').addClass( 'test' )
} );;
但我在浏览器控制台中收到错误:
[Error] ReferenceError: Can't find variable: $