I am developing a client side export table plugin. The plugin works great. But when I checked my code in jshint, it gave me an error, talking about a possible serious violation. Below is the function:
function disableExport(){
if(_(this).exportPlugin !== undefined){
_(this).exportPlugin.setStyle('pointer-events', 'none');
_(this).exportPlugin.find('.ebIcon').removeModifier('interactive','ebIcon');
_(this).exportPlugin.find('.ebIcon').setModifier('disabled','','ebIcon');
}else{
console.log('ERROR!');
}
}
And he says: "If a strict mode function is executed by calling the function, its value 'this' will be undefined."
The full plugin code is available at https://jsfiddle.net/t47L8yyr/
How to resolve this? any other solution than using/*jshint validthis:true*/
Valay source
share