admin管理员组文章数量:1386846
I have a remote form in my rails app:
<%= form_for(@list_item, :remote => true) do |f| %>
.............
.............
<%= f.submit("Add It!", class: "btn") %>
<% end %>
It's contained in a Bootstrap modal with id 'addListItem'. I want to dismiss this modal after submitting the form. I've found a few similar questions on SO, but none that has answered this in a way that prevents the form from submitting BEFORE the modal is closed. Help please?
I have a remote form in my rails app:
<%= form_for(@list_item, :remote => true) do |f| %>
.............
.............
<%= f.submit("Add It!", class: "btn") %>
<% end %>
It's contained in a Bootstrap modal with id 'addListItem'. I want to dismiss this modal after submitting the form. I've found a few similar questions on SO, but none that has answered this in a way that prevents the form from submitting BEFORE the modal is closed. Help please?
Share Improve this question asked May 6, 2014 at 1:42 setthelinesettheline 3,3938 gold badges34 silver badges65 bronze badges 2- Are you responding w/ a js.erb template on your create action? – Helios de Guerra Commented May 6, 2014 at 2:28
- No, there's nothing to update on the page. – settheline Commented May 6, 2014 at 3:13
2 Answers
Reset to default 4To dismiss the modal after form submit.
JavaScript
$('#form_id').on('submit', function() {
$('#addListItem').modal('hide');
});
Add a click event on your submit button using jQuery:
$('.btn').click(function() {
$('#addListItem').modal('toggle');
});
本文标签: javascriptClose Boostrap Modal AFTER form submitRailsStack Overflow
版权声明:本文标题:javascript - Close Boostrap Modal AFTER form submit - Rails - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744531982a2611089.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论