为什么对话框第一次打开我的对话框?

时间:2013-08-04 02:31:58

标签: asp.net-mvc-4 razor modal-dialog

我有一个div(mvc4 razor):

<div onclick='dialogtrigger(this)'>send</div>

当用户点击这个div时,它会在弹出对话框中加载一个视图并显示给用户。

它在用户第一次点击它时工作正常,之后当用户关闭对话框并想再次重新打开时它会给我这个错误:

0x800a01b6 - JavaScript runtime error: Object doesn't 
support property or method 'dialog'

我清理浏览器缓存并检查我的脚本文件,如果它不支持对话框,为什么第一次有效?

我的功能代码:

$.ajax({
    url: "OpenSendDialog",
    type: "GET",
})
.done(function (result) {
    $("#clientdetailmodal").html(result).dialog({
        autoOpen: true, modal: true, show: {
            effect: "blind",
            duration: 500
        }
    });
});
}

在我的主视图中:

<div id="clientdetailmodal"></div>

和我的控制员:

 [HttpGet]
 public ActionResult OpenSendDialog()
  {
    return view();
  }

1 个答案:

答案 0 :(得分:0)

我认为你的功能及其范围存在问题......

here,我希望能帮到你:

var dialogtrigger=null; // global scope
$(function() {
  dialogtrigger = function (){
      //replace with your ajax call
      $("#clientdetailmodal").html($('#content')).dialog({
          autoOpen: false, modal: true, show: {
              effect: "blind",
              duration: 500
          }
      });      
  }

$( "#opener" ).click(function() {
  // or destruct your modal on close and re-call your ajax
  $( "#clientdetailmodal" ).dialog( "open" );

});

});