From f3c9f8ce3beb9d0189ac3a6e91c59b245a39226c Mon Sep 17 00:00:00 2001 From: Patrick Galbraith Date: Fri, 22 Aug 2014 17:20:36 +0930 Subject: [PATCH 1/3] Fix "Cannot read property 'class_group' of undefined" Referencing `this` inside jquery.each scope when it should be `m` since the minimalect scope is replaced by the jquery function scope. --- jquery.minimalect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.minimalect.js b/jquery.minimalect.js index e853ca1..37bc33a 100644 --- a/jquery.minimalect.js +++ b/jquery.minimalect.js @@ -314,9 +314,9 @@ // parse each group separately this.element.find("optgroup").each(function(){ // create a group element - ulcontent += '
  • '+$(this).attr("label")+'
  • '; + ulcontent += '
  • '+$(this).attr("label")+'
  • '; // and add its children - ulcontent += this._parseElements( $(this).html() ); + ulcontent += m._parseElements( $(this).html() ); }); } return ulcontent; From 42ad48c494e16613067742453833fed4cd81ca4a Mon Sep 17 00:00:00 2001 From: Patrick Galbraith Date: Mon, 25 Aug 2014 12:43:50 +0930 Subject: [PATCH 2/3] Fix ajax and live issues I ran into an issue where the input is cleared immediately when typing if live = true. Changing live to false fixed the issue. But I needed to patch the _selectChoice function otherwise the items array is outdated when selecting. --- jquery.minimalect.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.minimalect.js b/jquery.minimalect.js index 37bc33a..ade4b01 100644 --- a/jquery.minimalect.js +++ b/jquery.minimalect.js @@ -212,7 +212,7 @@ } // poll the original for changes - if(op.live){ + if(op.live && !op.ajax){ // set cache to the original value var prevval = this.element.val(); // set a tight interval to check for the original @@ -546,6 +546,9 @@ // if it's disabled, au revoir if(ch.hasClass(this.options.class_disabled)) return false; + + if(!op.live) + this.items = this.wrapper.find('li'); // apply the selected class if(!this.element.prop("multiple")) From f2529ff3fa8bc96a589ee0b15d9ca4e67236c3e5 Mon Sep 17 00:00:00 2001 From: Patrick Galbraith Date: Mon, 25 Aug 2014 12:51:18 +0930 Subject: [PATCH 3/3] Small change to force op.live to false if ajax option is set --- jquery.minimalect.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.minimalect.js b/jquery.minimalect.js index ade4b01..0e8d0fb 100644 --- a/jquery.minimalect.js +++ b/jquery.minimalect.js @@ -78,6 +78,9 @@ var op = this.options, m = this; + + if(op.ajax) + op.live = false; // create the wrapper this.wrapper = $('
    '); @@ -212,7 +215,7 @@ } // poll the original for changes - if(op.live && !op.ajax){ + if(op.live){ // set cache to the original value var prevval = this.element.val(); // set a tight interval to check for the original