1

I have created plugin which do particular things with data, now I would like somehow join my plugin to use if with ex. jQuery dialog. How can I do this?

this is simplified situation:

(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);

but I always get that jQuery method dialog is undefined. I tried it in many ways but always get same error. I would be glad for help! thanks! :)

2
  • have u included the jquery ui Commented Jan 22, 2013 at 11:17
  • I have included it in main html file before including my plugin Commented Jan 22, 2013 at 11:18

1 Answer 1

1

Use jQuery(this).dialog() instead of jQuery.dialog(this)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.