2010-11-14 172 views
3

我與jQuery UI和MVC3試驗和我偶然發現了以下問題jQuery UI的彈出式內AJAX形式:問題與IE8

我有一個使用AJAX

<%: Ajax.ActionLink("Edit", "Edit", new { id = 1 }, new AjaxOptions() { UpdateTargetId = "dialog", OnSuccess = "DisplayPopup" }, null)%> 

<div id="dialog" title="Location"> 

</div> 

這是非常基本的網頁控制器的代碼:

public ActionResult Edit(int id) 
    { 
     return PartialView(); 
    } 

    [HttpPost] 
    public ActionResult Edit() 
    { 
     return Content("Saved!"); 
    } 

和局部視圖編輯:

<b>whatever</b> 

<% using (Ajax.BeginForm("Edit", "Home", 
    new AjaxOptions() 
    { 
     UpdateTargetId = "editForm", 
     HttpMethod = "POST" 
    })) 
{%> 
<div id="editForm"> 
    <input type="submit" value="Save" /> 
</div> 
    <% } %> 

上面的代碼工作正常。

現在我添加了jQuery UI彈出代碼:

<script type="text/javascript"> 
    function DisplayPopup() { 
     $('#dialog').dialog('open'); 
    } 

    $('#dialog').dialog({ 
     autoOpen: false, 
     width: 600, 
     modal: true, 
     buttons: { 
      "Close": function() { 
       $(this).dialog("close"); 
      } 
     } 
    }); 
</script> 

後,在Firefox和Chrome能正常工作,而在IE8我看到了以下問題:

  1. 點擊編輯 - 讓AJAX調用Edit(int id)動作並顯示彈出窗口中的編輯視圖
  2. click save - 使AJAX調用Edit()並顯示文本「Saved!」
  3. 關閉彈出
  4. 點擊編輯 - AJAX調用編輯(INT ID) - 再次
  5. 點擊保存 - 這一次它充分回傳(僅適用於IE)

什麼想法?

謝謝!

+2

我剛剛做了thickbox(http://jquery.com/demo/thickbox/)而不是jQuery UI彈出窗口,它在所有三種瀏覽器中工作正常...... – Slav 2010-11-14 16:37:45

+0

看起來像可能存在jqueryUI的問題模式對話框 - 我在這裏提交了一個bug ticket http://bugs.jqueryui.com/ticket/6679 – Slav 2010-11-21 17:52:42

+0

嘗試銷燬close事件上的對話框並在displaypopup函數中每次創建對話框new – jnoreiga 2011-03-14 16:43:19

回答

0

嘗試這看到它的作品第一次,但不是第二次。每次創建新的對話框並在完成後將其銷燬。

<script type="text/javascript"> 
    function DisplayPopup() { 
     $('#dialog').dialog({ 
     autoOpen: true, 
     width: 600, 
     modal: true, 
     buttons: { 
      "Close": function() { 
       $(this).dialog("close"); 
      } 
     }, close: function() { 
       $(this).dialog("destroy"); 

      } 
    }); 
    } 


</script> 
0

我有同樣的麻煩:工作在FF,但不是在IE8。

嘗試在局部視圖響應中添加一些內容。

我在IE中遇到了同樣的問題,並最終在局部視圖響應中添加了@ViewBag.Message,其中ViewBag.Message = "Submitted " + DateTime.Now.ToLongTimeString();已在Post上的控制器中分配。

這突然令人驚訝地導致局部視圖在正確的目標元素中呈現,而不是在IE8中加載視圖作爲新頁面。