javascript - Add a public function to a jquery plugin, to be called from another script -
i'm using adobe accessible mega menu plugin , looking extend this, (basically add function can called script).
i've looked extending jquery plugins, javascript closures , various other threads on subject and can see how works
i can see bunch of public attributes , methods (ln 695 on) attempting call these merely returns jquery object?
equally adding function , attempting call doesn't seem work?
i've added function called testfunction fires alert , should (i think) called :
$("nav:first").accessiblemegamenu("testfunction");
but no luck far..
does know how can add function above script, can called script?
https://codepen.io/anon/pen/vjzkqe
edit: solved - functions need accessed through prototype obj in :
nav.accessiblemegamenu.accessiblemegamenu.prototype.customfunction(param);
i have implemented approach on project using extend function jquery , prototype extend infinitescroll plugin can take approach , implement plugin hope useful
$.extend($.infinitescroll.prototype, { fucntion1: function() { //function implementation }, fucntion2: function() { //function implementaion } });
take question best way extend jquery plugin
Comments
Post a Comment