0

I am trying to make my custom draggable widget with JQuery Ui factory, which inherits draggable.

It works fine when the element itself, but I need to use draggable only on its child element. Is it possible to use with ihreritance or I should use just apply draggable as usual?

    $.widget("ui.myDraggable", $.ui.draggable, {

        options: {
            item: null //Selector for child element
        },

        _build: function() {

            var $item = $(this.options.item);

            //This makes container draggable
            $.ui.draggable.prototype._create.call(this);

            //How can I make only inner draggable, if I still apply widget on container?
            //Something like this:
            //$.ui.draggable.prototype._create.call(this.options.item);           

        }
}

Here is my complete example: http://jsfiddle.net/vlrt/j1uogfrx/4/

2
  • You can't (ok, you can, but shouldn't) do this, think of the recursion! Just make two widgets -- one for the parent and one for the child node. On a side note, don't call the "parent"-widget's initialiser that way, use this._super(). Commented Jan 16, 2015 at 10:05
  • Thanks a lot. Is it safe enough to apply draggable inside other widget? jsfiddle.net/vlrt/j1uogfrx/6 Commented Jan 16, 2015 at 10:48

0

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.