Override "private" function in JavaScript

Viewed 5603

I'm monkey-patching some of the jQuery's Draggable code*.

The goal is to avoid modifying the original source files and patch dynamically one of the internal functions.

The function _generatePosition is declared like this:

(function($) {

    $.widget("ui.draggable", $.ui.mouse, {
        ...
        _generatePosition: function(event) {
            ...
        }
    }
})(jQuery);

Is it possible to achieve the dynamic replacement of it?


*So it calculates the snapping grid relative to the top of parent element and not relative to the top of element being dragged. See here for more details.

3 Answers
Related