我创建了一些插件,用数据做特定的事情,现在我想以某种方式加入我的插件,如果用ex。 jQuery对话框。我怎么能这样做?
这是简化的情况:
(function($) {
$.fn.jquerytoc = function(map, layersConfig, layersList) {
var opts = $.extend($.treeview, $.fn.jquerytoc.defaults, map, layersConfig, layersList);
var TOC = {
map : opts.map,
layersConfig : opts.layersConfig,
TOCinfos : {},
getRequiredData : function() {
},
init : function() {
this.getRequiredData();
}
};
var HTML = {
nodes : TOC.TOCinfos,
data : [],
htmlObject : {},
jqTreeObject : {},
setHTMLcode : function() {
var object = this.data;
var objectNode = {};
var nodes = this.nodes;
console.log(nodes);
for (var node in nodes) {
objectNode = {};
objectNode.label = nodes[node].name;
objectNode.children = [];
var sublayers = nodes[node].sublayers;
for (var sublayer in sublayers) {
objectNode.children.push({
'label' : sublayers[sublayer]
});
};
object.push(objectNode);
};
},
init : function(object) {
this.htmlObject = object;
this.setHTMLcode();
}
};
function init() {
TOC.init();
HTML.init(this);
}
return this.each(function() {
init();
//AND HERE I WOULD LIKE TO WRAP MY DOM ELEMENT WITH JQUERY DIALOG
jQuery.dialog(this);
});
}
})(jQuery);
但我总是得到jQuery方法对话框是undefined
。我在很多方面尝试过但总是得到同样的错误。我很乐意帮忙!谢谢! :)
答案 0 :(得分:1)
使用jQuery(this).dialog()
代替jQuery.dialog(this)