overriding a javascript function (Superfish in Drupal) -


here superfish library used in drupal. superfish.js file @ line 102 contains code:

$.fn.extend({     hidesuperfishul : function(){         /* statements */     },     showsuperfishul : function(){         /* statements */     } }); 

i need override these 2 functions. how it? (i don't mean how in drupal specifically, rather how in javascript)

p.s. based on information, tried adding code in own script:

(function ($) {   var orig_hidesuperfishul = $.hidesuperfishul;     $.hidesuperfishul = function(){       alert('lol');     } })(jquery); 

firebug shows statement starting "var" runs once page refreshed, statement "alert" not run. instead, original hidesuperfishul function runs.

[edit 1] changed custom code to:

(function ($) {   //var orig_hidesuperfishul = $.hidesuperfishul;   var hidesuperfishul = function(){     alert('lol');   } })(jquery); 

[edit 2] added 4 breakpoints:

  1. in superfish.js @ line 102 code $.fn.extend({
  2. in superfish.js @ line 106 code o.retainpath = false;
  3. in script @ line var hidesuperfishul = function(){
  4. in script @ line alert('lol');

after refreshing page, code @ breakpoint 1 runs first, @ breakpoint 3. after moving mouse on , off menu, code @ breakpoint 2 runs. breakpoint 4 not reached.

the call stack @ breakpoint 1 2 anonymous functions (the first outermost function jquery argument, second breakpoint). similar call stack @ breakpoint 3.

the code overrides function in question is:

$.fn.hidesuperfishul = function(){(...)} 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -