Javascript 引导模式表单未在rails 5中提交给用户
我在模态中有表单,希望创建一个用户。当我单击“提交”时,不会发生任何事情。Javascript 引导模式表单未在rails 5中提交给用户,javascript,jquery,html,ruby-on-rails,ajax,Javascript,Jquery,Html,Ruby On Rails,Ajax,我在模态中有表单,希望创建一个用户。当我单击“提交”时,不会发生任何事情。 如何在使用Ajax的rails应用程序中提交模式表单并将模式内容保存在其他页面中 <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@getbootstrap">Open modal for @getbootstrap</button&
如何在使用Ajax的rails应用程序中提交模式表单并将模式内容保存在其他页面中
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@getbootstrap">Open modal for @getbootstrap</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">New message</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="text" class="col-form-label">firstname:</label>
<input class="form-control" id="text2"></input>
</div>
<label for="text" class="col-form-label">lastname:</label>
<input class="form-control" id="text2"></input>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data- dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">submit</button>
</div>
</div>
@getbootstrap的打开模式
新消息
&时代;
名字:
姓氏:
关
提交
单击提交按钮,文本字段值将通过Ajax方法传递给控制器
$(文档).ready(函数(){
$(“#提交”)。单击(函数(){
警报($(“#name”).val());
});
$.ajax({
键入:“POST”,
url:'path/to/controller',
数据:{'value':$(“#name”).val()}
});
});代码>
开放模态
&时代;
模态头
模态中的一些文本
关
首先使用CodeProject。感谢您的帮助@Ragavi