Skip to content

Commit 3b17638

Browse files
committed
really destroy instance on destroy method (fixes #160)
1 parent 3ae5b4e commit 3b17638

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/jquery-ias.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@
400400
*/
401401
IAS.prototype.destroy = function() {
402402
this.unbind();
403+
404+
this.$scrollContainer.data('ias', null);
403405
};
404406

405407
/**
@@ -547,32 +549,28 @@
547549

548550
this.each(function() {
549551
var $this = $(this),
550-
data = $this.data('ias'),
552+
instance = $this.data('ias'),
551553
options = $.extend({}, $.fn.ias.defaults, $this.data(), typeof option == 'object' && option)
552-
;
554+
;
553555

554556
// set a new instance as data
555-
if (!data) {
556-
$this.data('ias', (data = new IAS($this, options)));
557+
if (!instance) {
558+
$this.data('ias', (instance = new IAS($this, options)));
557559

558-
$(document).ready($.proxy(data.initialize, data));
560+
$(document).ready($.proxy(instance.initialize, instance));
559561
}
560562

561563
// when the plugin is called with a method
562564
if (typeof option === 'string') {
563-
if (typeof data[option] !== 'function') {
565+
if (typeof instance[option] !== 'function') {
564566
throw new Error('There is no method called "' + option + '"');
565567
}
566568

567569
args.shift(); // remove first argument ('option')
568-
data[option].apply(data, args);
569-
570-
if (option === 'destroy') {
571-
$this.data('ias', null);
572-
}
570+
instance[option].apply(instance, args);
573571
}
574572

575-
retval = $this.data('ias');
573+
retval = instance;
576574
});
577575

578576
return retval;

0 commit comments

Comments
 (0)