diff --git a/docs/api.md b/docs/api.md
index 2fd42f802..840a59c78 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -195,6 +195,10 @@ var selectize = $select[0].selectize;
isFull() |
Returns whether or not the user can select more items. |
+
+ clearCache(template) |
+ Clears the render cache. Takes an optional template argument (e.g. "option", "item") to clear only that cache. |
+
### Related Objects
diff --git a/src/selectize.js b/src/selectize.js
index 6729778d3..b19909c95 100644
--- a/src/selectize.js
+++ b/src/selectize.js
@@ -1830,6 +1830,23 @@ $.extend(Selectize.prototype, {
}
return html;
+ },
+
+ /**
+ * Clears the render cache for a template. If
+ * no template is given, clears all render
+ * caches.
+ *
+ * @param {string} templateName
+ */
+ clearCache: function(templateName) {
+ var self = this;
+ if (typeof templateName === 'undefined') {
+ self.renderCache = {};
+ } else {
+ delete self.renderCache[templateName];
+ }
}
+
});
diff --git a/test/api.js b/test/api.js
index 53abb27ba..2c2f10c92 100644
--- a/test/api.js
+++ b/test/api.js
@@ -567,6 +567,41 @@
});
});
+ describe('clearCache()', function() {
+ var test;
+
+ before(function() {
+ test = setup_test('