[英]jQuery detach IE issue?
For tab persistence in Backbone, I am saving the backbone view for that tab (say tab1) and detaching it from DOM. 为了实现Backbone中的选项卡持久性,我保存了该选项卡的主干视图(例如tab1),并将其与DOM分离。 Later when the user comes back to the tab1 the saved view is rendered.
稍后,当用户返回tab1时,将呈现已保存的视图。
I am saving the page state ie the backbone view as - 我将页面状态(即主干视图)保存为-
this.pageState = $(this.bodyContainer.$el.find(".pageContent"));
$(this.bodyContainer.$el.find(".pageContent")).detach();
This works perfectly on ff and chrome but for IE I have to do the following work around for IE - 这在ff和chrome上完美运行,但是对于IE,我必须针对IE做以下工作-
if($.browser.msie)
this.pageState = $(this.bodyContainer.$el.find(".pageContent")).clone();
else
this.pageState = $(this.bodyContainer.$el.find(".pageContent"));
$(this.bodyContainer.$el.find(".pageContent")).detach();
Is there a jQuery detach issue for IE? IE是否存在jQuery分离问题? Is there a better way to copy view that works for all browsers?
有没有更好的方法来复制适用于所有浏览器的视图?
I am not sure if this is awesome or not: 我不确定这是否很棒:
var pageStateElem = $(this.bodyContainer.$el.find(".pageContent"));
this.pageState = $.browser.msie ? pageStateElem.clone() : pageStateElem;
pageStateElem.detach();
I only removed some of the repetition from your code. 我只是从您的代码中删除了一些重复。 :-p
:-p
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.