2013-05-19 65 views
0

我有一個頁面顯示數據庫中的項目列表和添加新項目的文本框。當頁面第一次呈現時,列表在IE中正確顯示,但是當我添加一個新項目時,列表在IE 8中不會更新。這可以在Chrome中正常工作。這裏是我的代碼:敲除綁定在IE 8中沒有更新

self.ListOfDepartments.GetListOfAllDepartments = function() { 
    $.getJSON('/Department/ListAllDepartments', function (data) { 
     var mapped = ko.mapping.fromJS(data); 
     self.ListOfDepartments(mapped); 
    }); 
}; 

self.AddDepartmentModel.AddDepartment = function() { 
    self.errors = ko.validation.group(this, { deep: true, observable: false }); 
    if (self.AddDepartmentModel.errors().length == 0) { 
     $.ajax({ 
      url: "/Department/Add/", 
      type: 'post', 
      data: ko.toJSON(self.AddDepartmentModel), 
      contentType: 'application/json', 
      success: function (result) { 
       $('#success').html('Department Added Successfully.'); 
       $("#success").dialog({ 
        dialogClass: 'noclose', 
        autoOpen: true, 
        show: "blind", 
        hide: "explode", 
        modal: true, 
        open: function(event, ui) { 
         setTimeout(function() { 
          $('#success').dialog('close'); 
         }, 3000); 
        } 
       }); 
       Department.DepartmentName(null); 
       Department.DepartmentName.isModified(false); 
       self.ListOfDepartments.GetListOfAllDepartments(); 

      } 
     }); 
    } else { 
     self.AddDepartmentModel.errors.showAllMessages(); 
     return; 
    } 
}; 

HTML:

<div data-bind="foreach: ListOfDepartments()"> 
     <div data-bind="text: DepartmentName" class="margin textStyle"></div> 
    </div> 

當如果添加成功,我的網頁在IE瀏覽器不更新的列表GetLIstOfAllDepartments被調用。有什麼特別的,需要爲IE做?

回答

2

找到了解決方案。 IE緩存阿賈克斯請求只是關閉緩存:

$.ajaxSetup({ 
    cache: false 
});