0

I am trying to insert inline js in one of my haml templates.

As a test, I tried this answer @ 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' )
        } );;

but I get an error in the browser console :

[Error] ReferenceError: Can't find variable: $
Community
  • 1
  • 1
  • 1
    Is jQuery imported into the document sometime before that point? – Pointy Sep 28 '14 at 13:11
  • got it ... I wrote the application.js tag at the end of the layout... when I move it back into the head.. it's working fine.. no way to keep it at the end I guess –  Sep 28 '14 at 13:25

0 Answers0