سؤال

I need to use apply() or call() method on an object instance method of DHTMLX layout. The following works as expected:

A.setSkin('dhx_web');

However when using apply() an error is generated

A.setSkin.apply(undefined,['dhx_web']);


A.setSkin.call(undefined,'dhx_web');


Uncaught TypeError: Cannot read property 'dhx_web' of undefined 
هل كانت مفيدة؟

المحلول

The first parameter should be specified. It will set the value of this inside the setSkin function.

A.setSkin.apply(A, ['dhx_web']);
A.setSkin.call(A, 'dhx_web');
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top