Reputation: 12384
This is code to destroy and initialize a jquery plugin cubeportfolio (I don't think this is specific to cubeportfolio).
jQuery('#some-grid').cubeportfolio('destroy');
jQuery('#some-grid').cubeportfolio(options);
If I want to re-initialize it, I first need to destroy it, which works fine if it already exists.
But I get an error if I try to destroy an instance, that does not already exists (which makes complete sense).
How can I check if cubeportfolio is already initialized on #some-grid?
Upvotes: 1
Views: 624
Reputation: 2323
You can use
Boolean($('#some-grid').data('cubeportfolio'))
to check if an instance of cubportfolio
already exists on the given element
Upvotes: 2