I’m trying to create an instance from another library on _create and the access this from private and public functions in my widget. Is this possible?
$.widget('namespace.pluginName', {
_create: function() {
// Create instance from other library on create
var someovar = otherlibrary.function(options);
},
_privatemethod: function() {
var self = this;
// Call "samovar" instance?
self._create.somevar.function( "option", function() {
// Do sutff
});
}
}));
I also like to cache my selections only once like this: var div = $('#my_div'); on _create. Right now I need to reselect the same div in 10 different functions. Is this the way to do it or should I just ignore the caching?
Thanks!
I haven’t tested, but try to do it like this:
Alto $.widget() takes 3rd parameter, which is your widget prototype (another object). Maybe it can be somehow useful in your case – for example to store mentioned caches.