ie7和ie8中的Jquery ui小部件副本

时间:2013-01-16 10:37:36

标签: javascript jquery-ui internet-explorer

我在jquery ui上遇到了一个奇怪的行为(在jquery 1.8.3,jquery-ui 1.9.2上测试过)。

我有一个父和子窗口小部件,在父窗体的_create方法上,我给父母自己引用了新创建的子窗口。 当我尝试从子项中访问此引用时,在构建子项后声明的所有函数和属性都不可用。

(function ($) {
  $.widget("ui.parentWidget", $.ui.mouse, {
    version: "@VERSION", widgetEventPrefix: "parentWidget",

_create: function () {
  var self = this;
  self.child = $("<div/>")
    .childWidget({ parent: self })
    .appendTo(self.element);
  self.parentName = "parent";
},

parentFeature: function() {
    return "feature";
},

getChild: function() {
    return this.child;
},

updateChild: function () {
    var self = this;
    self.child.childWidget("update", self);
}
});}(jQuery));

子窗口小部件

(function ($) {
$.widget("ui.childWidget", $.ui.mouse, {
    version: "@VERSION", widgetEventPrefix: "childWidget",

    options: {
    },

    _create: function () {
    },

    childParent: function () {
        return this.options.parent;
    },

    updatedParent: function() {
        return this.newParent;
    },

    update: function(parent) {
        var self = this;
        self.newParent = parent;
    }
});
}(jQuery));

现在测试我的输出我只是创建一个父项,检索它的子项,并从子项中读取子项的父项并显示结果。

var parent = $("<div/>").parentWidget();
parent.parentWidget("updateChild");
var child = parent.parentWidget("getChild");
var childParent = child.childWidget("childParent");
var updatedParent = child.childWidget("updatedParent");
对于ie7和ie8,

childParent.parentNamechildParent.parentFeature()undefined,并在其他地方正常工作updatedParent拥有其所有内容。

我的问题是,这是一个错误吗?或者我误解了如何正确使用jquery ui插件。

0 个答案:

没有答案