summaryrefslogtreecommitdiffstats
path: root/readmore.js
diff options
context:
space:
mode:
Diffstat (limited to 'readmore.js')
-rw-r--r--readmore.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/readmore.js b/readmore.js
index 840d82f..e1332e2 100644
--- a/readmore.js
+++ b/readmore.js
@@ -130,6 +130,8 @@
},
destroy: function() {
+ var $this = this;
+
$(this.element).each(function() {
var current = $(this);
@@ -144,9 +146,12 @@
var args = arguments;
if (options === undefined || typeof options === 'object') {
return this.each(function () {
- if (!$.data(this, 'plugin_' + readmore)) {
- $.data(this, 'plugin_' + readmore, new Readmore( this, options ));
+ if ($.data(this, 'plugin_' + readmore)) {
+ var instance = $.data(this, 'plugin_' + readmore);
+ instance['destroy'].apply(instance);
}
+
+ $.data(this, 'plugin_' + readmore, new Readmore( this, options ));
});
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
return this.each(function () {