0

I am creating an application in Ruby. I have created a view for the user in which I have this button :

<%= link_to 'New message', new_message_path(cosplayer: @cosplayer.id), role: 'button', class: 'btn btn-info', remote: true %>

Linked do it I have this .js code in the js folder:

$(".message").html("<%= escape_javascript(render('shared/message_form')) %>") $("#newMessage").modal('show')

What happens is that when I run the website and I click on the button 'New Message' the .js file doesn't work and doesn't open the modal window. The page becomes less brighter as the window will appear, but it doesn't work. Is there anything I have to written in order to recognise the js file?

Thanks in advance.

6
  • Can I see the HTML the link_to helper is creating?
    – Anthony
    Jul 4, 2014 at 18:45
  • Yes, here it is: <div id="newMessage" class="modal hide fade"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4>A message for <%= @cosplayer.nickname %></h4> </div>
    – Stark_kids
    Jul 4, 2014 at 20:03
  • <h4>A message for <%= @cosplayer.nickname %></h4> </div>
    – Stark_kids
    Jul 4, 2014 at 20:06
  • <%= form_for(@message) do |f| %> <div class="modal-body"> <div class="field"> <%= f.hidden_field :sender, value: current_cosplayer.id %> <%= f.hidden_field :recipient, value: @cosplayer.id %>
    – Stark_kids
    Jul 4, 2014 at 20:06
  • <%= f.label :subject %> <%= f.text_field :subject, value: @message.subject %> <%= f.label :body %> <%= f.text_area :body %> </div> </div>
    – Stark_kids
    Jul 4, 2014 at 20:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.