0

以下のコードを使用してjQuery uiダイアログを作成しました。それはうまくいきました。しかし、閉じるボタンが機能していません。ダイアログに「取引を追加」ボタンを追加しました。ボタンをクリックすると、取引を追加するコントローラーアクションを呼び出したいと同時に、ダイアログが消えず、同じ内容が表示されます。この問題に対する提案はありますか。

<script type="text/javascript">
 $(function () {
     $('#divtrade').dialog({
         autoOpen: false,
         width: 1400,
         height: 600,
         resizable: false,
         title: 'New Trades',
         modal: true,
         buttons: {
             "Close": function () {
                 //close button not working
                 $('#divtrade').dialog("close");
             },
             "Add Trade": function () {
                   //how to invoke controller to add trade using jquery, at the same time
                   //dialog should not disappear, it should show the previous view
             }
         }
     });
 });


$('.newtrade').click(function () {
    $('#divtrade').load('@Url.Action("NewTrade","Trade")').dialog('open');

});
   </script>

  <div id="divtrade"  style="display:none;"></div>
4

1 に答える 1

0

このようなものを追加します:

$.ajax(
   url:'@Url.Action("YourAction","YourController")',
   success : function(data){
      $('#divtrade').html(data);
      $('#divtrade').show();
      // You may consider to close the dialog after loading the content
      $('#divtrade').dialog("close");
   }
);

jQueryAjaxの詳細が必要な場合

于 2012-06-24T10:32:10.380 に答える