Javascript jQuery上的提交函数无法在表单上工作(使用HAML)

Javascript jQuery上的提交函数无法在表单上工作(使用HAML),javascript,jquery,ruby-on-rails,haml,Javascript,Jquery,Ruby On Rails,Haml,我有以下jQuery代码来检测提交事件并触发一些其他javascript代码: $('form#send-message').on('submit', function(){ console.log('test'); $('body').modalmanager('loading'); }); 但是,这不适用于: .modal-header Contact info %button.close{ :type => 'button', 'data-d

我有以下jQuery代码来检测提交事件并触发一些其他javascript代码:

$('form#send-message').on('submit', function(){
      console.log('test');
      $('body').modalmanager('loading');
    });
但是,这不适用于:

.modal-header
  Contact info
  %button.close{ :type => 'button', 'data-dismiss' => 'modal', 'aria-hidden' => 'true' }
    ×
.modal-body
  = raw @booth.contact_info
  %hr
  = simple_form_for(@booth, url: booth_send_message_path, method: :post, html: { id: "send-message" }, remote: true) do |f|
    .form-group
      %textarea#message.form-control{name: "user[message]", placeholder: "Type your message here..."}
    %input{type: "hidden", name: "user[id]", value: "#{current_user.id}"}
    .form-actions
      %button.btn.btn-warning{:type => 'submit'} Send
      = f.error_notification
表单的id绝对匹配,但似乎没有触发任何内容

是否存在该事件不起作用的原因

input type=submit and button type=submit 
这是不同的事情。所以,只需将按钮更改为输入或将回调绑定到按钮单击事件

%input.btn.btn-warning{:type => 'submit'} Send
在haml文件中尝试以下操作:

.form-actions
  = f.button :submit, 'Send', class: 'button btn btn-warning'

%button.btn.js_submit_form.btn警告{:type=>'submit'}Send,$(“.js_submit_form”)。在(“单击”,函数(){//logic return false;});