From 4cd029044d61219b71a45379426742ae59172df9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 31 Jul 2015 16:14:59 -0400 Subject: [PATCH] Add destroy methods for crmEntityRef and crmSelect2 --- js/Common.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/Common.js b/js/Common.js index ff3ddbe987..4dd1a05783 100644 --- a/js/Common.js +++ b/js/Common.js @@ -362,6 +362,13 @@ CRM.strings = CRM.strings || {}; * @param options object */ $.fn.crmSelect2 = function(options) { + if (options === 'destroy') { + return $(this).each(function() { + $(this) + .removeClass('crm-ajax-select') + .select2('destroy'); + }); + } return $(this).each(function () { var $el = $(this), @@ -396,6 +403,15 @@ CRM.strings = CRM.strings || {}; * @param options object */ $.fn.crmEntityRef = function(options) { + if (options === 'destroy') { + return $(this).each(function() { + var entity = $(this).data('api-entity') || ''; + $(this) + .off('.crmEntity') + .removeClass('crm-form-entityref crm-' + entity.toLowerCase() + '-ref') + .crmSelect2('destroy'); + }); + } options = options || {}; options.select = options.select || {}; return $(this).each(function() { -- 2.25.1