Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 425
Pinkie Avatar asked Dec 28 '22 00:12

Pinkie


2 Answers

Something like this, executed before the other script loads:

jQuery.fn.xdraggable = jQuery.fn.draggable;
like image 134
Matt Ball Avatar answered Dec 30 '22 14:12

Matt Ball


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

like image 26
Brad Christie Avatar answered Dec 30 '22 14:12

Brad Christie