我在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绝对匹配,但似乎没有触发
这个事件有效吗?
答案 0 :(得分:0)
input type=submit and button type=submit
是不同的事情。所以只需更改按钮即可输入或将回调绑定到按钮点击事件
%input.btn.btn-warning{:type => 'submit'} Send
答案 1 :(得分:0)
在haml文件中尝试:
.form-actions
= f.button :submit, 'Send', class: 'button btn btn-warning'