I have a rails application where I am trying to have jQuery render WITH an HTML file. The point of this is that the jQuery is specific to the page so I don't want it loading for every page by putting it in the header. Here's what I have done to the files
messages_controller.rb
# GET /messages/new
def new
@message = Message.new
@users = User.where('id != ' + current_user.id.to_s)
#if @message.save
#MessageMailer.new_message(@message).deliver
respond_to do |format|
format.html # new.html.erb
format.js
end
#end
end
/messages/new.html.erb
<div class=row>
<div class=large-12 columns>
<div class=panel>
<h1>New message</h1>
<%= render 'form' %>
<%= link_to 'Back', messages_path, :class => button small %>
</div>
</div>
</div>
/messages/new.js.erb
$(h1).html('hello'); //for testing that it works
Is there something that I have to add to another file? Is there a request I have to make so it loads both the HTML and .js?