Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法禁用jQuery模式对话框缓存_Jquery_Asp.net Mvc_Caching_Jquery Ui Dialog - Fatal编程技术网

无法禁用jQuery模式对话框缓存

无法禁用jQuery模式对话框缓存,jquery,asp.net-mvc,caching,jquery-ui-dialog,Jquery,Asp.net Mvc,Caching,Jquery Ui Dialog,我正在MVC4开发中使用模态对话框编辑记录。我正在使用ajaxform将更新的值提交给控制器。到目前为止,该功能运行良好。但是我面临着缓存的问题,我一直试图解决这个问题,但没有成功。 主页上的记录显示在各个选项卡中,每个选项卡都有一个编辑选项。单击编辑,我将在模态对话框上加载相应的局部视图。启动模态对话框并单击“取消”后,更改选项卡并再次单击“编辑”,对话框将正确加载相应的局部视图进行编辑。但是,如果我单击编辑启动模式对话框并更新值,然后再次从另一个选项卡加载模式弹出窗口,它将显示上一个选项卡的

我正在MVC4开发中使用模态对话框编辑记录。我正在使用ajaxform将更新的值提交给控制器。到目前为止,该功能运行良好。但是我面临着缓存的问题,我一直试图解决这个问题,但没有成功。 主页上的记录显示在各个选项卡中,每个选项卡都有一个编辑选项。单击编辑,我将在模态对话框上加载相应的局部视图。启动模态对话框并单击“取消”后,更改选项卡并再次单击“编辑”,对话框将正确加载相应的局部视图进行编辑。但是,如果我单击编辑启动模式对话框并更新值,然后再次从另一个选项卡加载模式弹出窗口,它将显示上一个选项卡的编辑视图,而不是我要编辑的视图。我已经调试了代码,但似乎不是代码问题。我曾尝试在模式对话框和应用程序级别禁用by cache:false,但没有任何效果!我正在添加模态启动jQuery和模态对话框表单代码的一段代码

   $(".model-edit").click(function () {
        var viewid = $(this).attr("id");
        var key = $("#KeyField").val();
        var functionurl = '@Url.Action("ShowEditModel")';

        if (key != "") {
            $.ajax({
                type: 'POST',
                url: functionurl,
                cache: false,
                context: this,
                data: { key: key, viewid: viewid },
                success: function (data) {
                    $('#model-editor').html(data);
                    $('#model-editor').dialog({ modal: true,
                        width: 'auto', resizable: false, autoOpen: false,
                        closeOnEscape: true, position: 'middle'

                    });
                    myModal = $('#model-editor').dialog('open');
                    $.validator.unobtrusive.parse("#EditForm");
                }
            });
        }
    });
模态对话框视图

@using (Ajax.BeginForm("UpdateRecord",null,null,new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", UpdateTargetId = "SelectedRecord", OnSuccess = "closeModal();" }, new { id = "EditForm" } ) )
{

    <table cellspacing="3" cellpadding="3" align="left" width="950px">
       <tr>
        <td align="center" colspan="3">
            <input type="hidden" value=@Model.CurrentStep id="CurrentStep" name="CurrentStep"/>
        </td>
       </tr>     
      <tr>
        <td  align="center">
         @for (int i = 0; i < ((string[])Model.StepView).Count(); i++)
         {
             if (i == (int)Model.CurrentStep)
             {
              <h2 class="StepTitle">@((string)Model.StepTitle[i])</h2>
             <div class="wizard-step" id=@i style="height:auto;position:relative;display:inherit">
               @Html.Partial((string)Model.StepView[i])
             </div>
             }
             else
             {
              <div class="wizard-step" style="height:auto;position:relative;">
               @Html.Partial((string)Model.StepView[i])
              </div>
             }
         }
        </td>
     </tr>
     <tr>
       <td align="center">
         <div id="buttons" class="actionBar">
           <input type="button" class="button" id="CancelButton" value="Cancel" onclick="closeModal();" />
           <input type="submit" class="button" id="SaveButton" value="Update" style="float:left"/>
         </div>
      </td>
    </tr>
    </table>

 <script type="text/javascript">

      function closeModal() {
         $(myModal).dialog('close');

     }

 </script>
}
@使用(Ajax.BeginForm(“UpdateRecord”,null,null,new AjaxOptions{InsertionMode=InsertionMode.Replace,HttpMethod=“POST”,UpdateTargetId=“SelectedRecord”,OnSuccess=“closeModal();”},new{id=“EditForm”}))
{
@对于(int i=0;i<((string[])Model.StepView.Count();i++)
{
if(i==(int)Model.CurrentStep)
{
@((字符串)Model.StepTitle[i])
@Html.Partial((字符串)Model.StepView[i])
}
其他的
{
@Html.Partial((字符串)Model.StepView[i])
}
}
函数closeModal(){
$(myModal).dialog('close');
}
}

我不确定是什么原因导致了问题,因为当我单击“取消”或使用X按钮关闭模态对话框时,它工作正常。但当我提交表单并使用相同的JavaScript关闭时就不会了

我发现了错误。我刚换了零钱

                $('#model-editor').dialog({ modal: true,
                    width: 'auto', resizable: false, autoOpen: false,
                    closeOnEscape: true, position: 'middle'

                });

                 $('#model-editor').html(data); <<= Moved this line after modal initialization
                  myModal = $('#model-editor').dialog('open'); 
                 $.validator.unobtrusive.parse("#EditForm");
$(“#模型编辑器”)。对话框({modal:true,
宽度:“自动”,可调整大小:false,自动打开:false,
closeOnEscape:正确,位置:'中间'
});

$(“#模型编辑器”).html(数据) 我想你应该试试

dialog('destroy') instead dialog('close')