0

当用户单击添加时,我想关闭以下对话框:

<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 的陈述。感谢您的任何提示。

4

1 回答 1

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>

应该工作,如果没有,请更新我。

于 2013-05-23T17:38:51.680 回答