How to overload a JavaScript function? (changing Slickgrid's editor) -


i'm using slickgrid , change behavior of editor. instead of copy&paste tried overload 1 of functions doesn't work. cannot read loadvalue function.

loadvalue defined (some code omitted)

    integercelleditor : function(args) {         this.loadvalue = function(item) {             defaultvalue = item[args.column.field];             $input.val(defaultvalue);             $input[0].defaultvalue = defaultvalue;             $input.select();         };     } 

what tried is:

    function tristateintegercelleditor(check_field) {          var f = integercelleditor;         var f_loadvalue = f.loadvalue;          f.loadvalue = function(item) {             f_loadvalue(item);              if (check_field) {                 if (!item[check_field]) {                     $select.disable();                 }             }         };          return f;     } 

is there way substitute function?

you need f_loadvalue.call(this, item);

otherwise old loadvalue get's called it's context (this) window (the default).

related:


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -