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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -