在提交按钮上关闭jquery对话框
当用户单击“添加”时,我想关闭以下对话框:在提交按钮上关闭jquery对话框,jquery,ruby-on-rails,Jquery,Ruby On Rails,当用户单击“添加”时,我想关闭以下对话框: <head> <script> $(function() { $( "#dialog" ).dialog(); }); </script> </head> <body> <div id="dialog" title="Select Item"> <%= for
<head>
<script>
$(function() {
$( "#dialog" ).dialog();
});
</script>
</head>
<body> <div id="dialog" title="Select Item">
<%= form_tag( {:controller => :foos, :action => :update_position, :position => @i , :id => @foo.id }, :remote => true) do %>
<td>
<%= select_tag :position_name, options_for_select(@selection_list) %>
</td>
<td>
<%= hidden_field_tag 'position', @i %>
<%= submit_tag "Add" , :class => "btn" %>
<script>
function() {
$( this ).dialog( "close" );
}
</script>
</td>
<% end %>
</div>
</body>
$(函数(){
$(“#dialog”).dialog();
});
:foos,:action=>:update_position,:position=>@i,:id=>@foo.id},:remote=>true)do%>
“btn”%>
函数(){
$(此).dialog(“关闭”);
}
我不知道如何安排RoR的陈述。感谢您提供的提示。如jqueryUI/dialog的API中所述: 更新第一个脚本的块:
<script>
$(function() {
$( "#dialog" ).dialog();
$( "#id-of-closing-button").click(function(){
$( "#dialog" ).dialog("close");
});
});
</script>
$(函数(){
$(“#dialog”).dialog();
$(“#关闭按钮的id”)。单击(函数(){
$(“对话框”)。对话框(“关闭”);
});
});
应该可以,如果不行,请更新我。我认为这个问题是100%jQuery和0%RoR。好吧,那么解决方案与表单标签没有任何关系?你是不是建议我在没有编码的rails的情况下提交数据?恐怕不行。您知道在我的示例中,我将用什么替换关闭按钮的#id吗。好吧,我给了我的提交按钮一个id,并将名称与脚本部分相匹配。我将添加到您的解决方案中。谢谢