我正在使用JQuery和Jquery UI创建一个包含自定义窗体的对话框。我有一个基本的对话框,它有一个附加到它的主体的工具。所以我的对话框的基本结构是JQuery UI框架>对话框> ToolBody>工具内容。.append()为不同的参数类型产生不同的结果
Code:
ToolManager.prototype.showTool = function(tool){
var $container = $("#" + this.id);
var $tool = $("#" + tool.id);
var $toolBody = $("#" + this.toolBodyId);
$container.dialog({
resizable: false,
modal: true,
width: tool.width,
stack: true,
height: 'auto',
draggable: true,
close: this.tearDown,
open: this.setup
});
$tool.removeClass("hidden");
$toolBody.append($tool.html());
//$toolBody.append($tool);
$container.show();
};
这工作,尽管它需要重构,但是使用这种方法,我尝试使用注释掉前行:
$toolBody.append($tool);
这种方法肆虐在我的布局混乱,造成附加的内容被阻止接收焦点。任何人都可以解释追加Jquery对象和附加一个html字符串之间的区别吗?或者为什么它以这种方式表现?
感谢解释非常有用的信息。你为什么说它是一个可怜的克隆,我会注意到接收方法绑定? –
没问题。这就是我们来这里的原因,对吧? :) –