当用户点击添加时,我想关闭以下对话框:
<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>
我不确定如何使用RoR安排语句。感谢您的任何提示。
答案 0 :(得分:1)
在jqueryUI / dialog的API中编写: http://api.jqueryui.com/dialog/#method-close
更新您的第一个脚本块:
<script>
$(function() {
$( "#dialog" ).dialog();
$( "#id-of-closing-button").click(function(){
$( "#dialog" ).dialog("close");
});
});
</script>
应该工作,如果没有,请更新我。