1

无法理解问题是什么。

在骨干集合上调用 remove 方法时,将模型传递给它集合被刷新,我看不到删除的模型,但在 IE9 中它不会刷新,直到我手动刷新页面。

当试图在 IE9 中收集 console.log 时,我得到了未定义。

在 IE10+ 和所有其他浏览器中,这可以正常工作。

我正在使用backbone.marionette 和使用requirecs 的coffeescript。

这是示例:

delete: ->
  @deleteDeferred = $.Deferred()
  vent.trigger 'modal:', name: 'deleteConfirm', modalSize: '', model: @
  promise = @deleteDeferred.then =>
    xhr = $.ajax
      url: "/api/v1/user-contact-data/#{@id}"
      dataType: 'json'
      type: 'DELETE'

  promise.done =>
    @collection.remove(@) if @collection

  promise.always =>
    delete @deleteDeferred

  promise

有什么想法吗?

谢谢。

4

2 回答 2

1

听起来 IE9 正在缓存您的 ajax 请求(不好玩=/)

尝试这个:

$.ajaxSetup({ cache: false });

这将添加一个“缓存破坏器”查询参数(一个毫秒时间戳),并确保每个 ajax 请求都是唯一的。

于 2013-10-30T21:33:32.307 回答
0

我只是好奇为什么你可以直接在模型上使用destroy方法时创建一个promise和XHR调用?例如:

# This will automatically call "/api/v1/user-contact-data/#{@id}", using the verb 
# DELETE, fire the appropriate events, 
# and remove it from any collection(s) the model is attached to
@model.destroy success: =>
    vent.trigger 'delete:successful'
于 2013-10-30T06:37:59.533 回答