apologies if this has been answered before, I couldn’t dig anything up when searching.
I am overriding jQuery validator’s highlight & unhighlight methods – but I wish to continue calling the ‘stock’ version of the methods also. In C# this would be like calling base.unhighlight, for example.
As it stands, I am forced to copy & paste code out of the original thus simulating a call to the parent.
jQuery.validator.setDefaults({
unhighlight: function (element, errorClass, validClass) {
// base.unhighlight(element, errorClass, validClass) // <-- desired functionality
...
How would I go about doing this? Thanks a lot–
With the way this is structured, that’s about the best you could do without modifying the plugin. The reason for this, is when you call the setDefault method, it overwrites the plugins own copy of the defaults. This proved hard to get around, but I fixed it by separating the defaults object out & and making a copy of it to refer back to. Honestly copying the simple logic from the plugin source might be the better route at this point, because you should only be calling setDefaults once for your entire implementation.
See my commits here & here. Feel free to fork if you wish.
Basically, now the function you’re calling has an extra param, _orig (or whatever you wish). Same goes for
highlight.Here’s the file
Edit: Wow. That plugin’s scope is waayy advanced. It took longer than I thought to implement my solution. Here’s a working demo: http://jsfiddle.net/fjMFk/24/