Pinkie
Pinkie

Reputation: 10246

How to rename a jQuery function

How do we rename a jquery function. let's say i want to rename the Jquery UI function draggble() to xdraggble() so that it does not conflict with another draggable function loaded from another library. Does renaming affect performance.

Upvotes: 4

Views: 3807

Answers (2)

Matt Ball
Matt Ball

Reputation: 359786

Something like this, executed before the other script loads:

jQuery.fn.xdraggable = jQuery.fn.draggable;

Upvotes: 8

Brad Christie
Brad Christie

Reputation: 101604

var xdraggable = $.fn.draggable;
//or
var xdraggable = $.draggable;

(depending implementation)

Same as what you'd do if you wanted to override the function but still have access.

See this post regarding what I mean by overriding

Upvotes: 2

Related Questions