Superfish JS is here.
Here’s the relevant code:
$.fn.extend({
hideSuperfishUl : function() {
// ...code here...
return this;
},
showSuperfishUl : function(){
// ...code here...
return this;
}
});
Questions:
Does $.fn.extend({...}); allow users to override hideSuperfishUl & showSuperfishUl functions? If so, what does the syntax look like to change these methods when calling the plugin:
<script>
$(document).ready(function() {
$('ul.sf-menu').superfish(); // How to override hideSuperfishUl &/or showSuperfishUl?
});
</script>
Superfish was written a while back… Is this still the best way to allow users to override plugin functionality functions/methods/other? If not, is there a “best” way?
Going to try to answer my own question here… Please correct me if anything I write below is wrong! 😉
This article says this:
The Superfish JS is using the same code found in the above quote; long story short,
showSuperfishUl()andhideSuperfishUl()are additional plugins in the jQuery$.fnnamespace.I was able to override said functions like so:
Next, this article says:
Conclusion:
Both
$.fn.extendand$.fn.pluginName.functionare similar and allow the end user to easily override functionality; the former adds new plugins to the jQuery$.fnnamespace, whereas the latter are functions which are contained within a single$.fn.pluginNamenamespace.Summary and Best Practices says:
… therefore, my pick for “best” technique is
$.fn.pluginName.function.