Здравствуйте! Пытаюсь сделать AJAX отправку формы из рельсового приложения используя jquery-ujs
Почему то не отрабатывает мой JS код, не пойму в чем дело :-(
По нажатию на кнопку отправить форму висит такое:
$(document).ready ->
$("#contact_form").on("ajax:success", (e, data, status, xhr) ->
$("#contact_form").append data
).on "ajax:error", (e, xhr, status, error) ->
$("#contact_form").append xhr.responseText
application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
Буду благодарен за любую помощь!
<div class="callback-form" id="callback-form">
<%= form_for :email,
:url => { :controller => 'pages', :action => 'send_mail' },
:class => "testclass",
:method => "POST",
:remote => true,
html: {id: "contact_form"} do |f| %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<%= f.label :name, 'Ваше имя' %>
<%= f.text_field :name, :class => 'name', :size => 60 %>
<%= f.label :telephone, 'Ваш номер телефона' %>
<%= f.text_field :telephone, :class => 'telephone', :size => 60 %>
<%= f.label :body, 'Сообщение' %>
<%= f.text_area :body, :rols => 10, :cols => 60 %>
<%= submit_tag "Оставить заявку", :class => 'btn-send-form' %>
<% end %>
</div>