I'm trying to pass 'this' to a callback function. I know a "suitable" way of doing this is setting this to a variable and using the variable... but that's not very elegant.
var that = this;
chrome.storage.sync.set(this.defaultOptions, function () {
that.loadOptions();
});
I'm trying something else, but I can't figure out how to do it. Here's what I have tried:
chrome.storage.sync.set(this.defaultOptions, (function () {
this.loadOptions();
}).call(this));
But it's not working out. I'm getting this error:
Error in response to storage.set: Error: Invocation of form
get(object, undefined) doesn't match definition
get(optional string or array or object keys, function callback)
Other questions on SO I've tried looking into have similar needs but not quite the same. How can I achieve what I want in the best way?