Tips and Tricks in a world of Mix

If you have a function in some plugin , that you would like to change to your own needs , you may use inheritance in a very simple way .
You are writting your own function , lets say : foo , and than using prototype method you add the new function instead of the original one.
For exmple in jquery.validate.js you have extend of the validator with function called showLabel.
You can create a new .js file , in which you’ll enter your own function , for instance :
MyFile.js :


function showLabelNewVersion(element, message) {...}

at the end just add this line to connect the new functionality to the old name of the function :


$.validator.prototype.showLabel = showLabelNewVersion;

Now when your plugin will try to use it’s showLabel it”ll get the content of the showLabelNewVersion.

Good luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: