From a0fd6726710e5a18489f57a20b042a881d4465e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bilal=20=C3=87=C4=B1narl=C4=B1?= Date: Wed, 16 Sep 2015 17:20:28 +0300 Subject: [PATCH 1/2] Cleanup method fixes, solved issue #8 --- lib/uxrocket.select.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/uxrocket.select.js b/lib/uxrocket.select.js index 49817d6..fa16ade 100644 --- a/lib/uxrocket.select.js +++ b/lib/uxrocket.select.js @@ -118,7 +118,7 @@ } $el.after( - '' + + '' + ' ' + $current + '' + ' ' + ''); @@ -173,15 +173,24 @@ }); $('body').on('DOMNodeRemoved', function(e) { - if(e.target === $el[0]) { - cleanUp(_opts.index) + var el = $el[0]; + + if(e.target === el) { + // select replaced or removed + // when Select options changed, update bindings + // via $.uxselect.update($el) method + if(e.originalEvent.relatedNode !== el) { + setTimeout(function() { + cleanUp(_opts.index); + }, 1); + } } }); }; var cleanUp = function(index) { - $('.' + ns.wrap + '-' + index).remove(); + $('.' + ns.current + '-' + index).unwrap().remove(); $('#' + ns.list + '-' + index).remove(); }; @@ -303,13 +312,14 @@ var _opts = $(this).data(ns.data), optionList = builtOptions($(this)), $current = setText($(this).find(':selected').text()); + $(this).next('.' + ns.current).find('.' + ns.text).text($current); $('.' + ns.list).filter('[data-select="' + $(this).attr('id') + '"]').replaceWith(optionList); + bindUIActions($(this)); + callback(_opts.onUpdate); }); - - bindUIActions($el); }; // remove @@ -349,7 +359,7 @@ }; // Version - ux.version = "2.8.0"; + ux.version = "2.8.1"; // settings ux.settings = defaults; From c23b15fc2fd211dd20d2bc7dce083dd219ba599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bilal=20=C3=87=C4=B1narl=C4=B1?= Date: Wed, 16 Sep 2015 17:20:58 +0300 Subject: [PATCH 2/2] version bump --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index b4b946e..c20a671 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "uxrocket.select", - "version": "2.8.0", + "version": "2.8.1", "homepage": "https://github.com/uxrocket/uxrocket.select", "authors": [ "Bilal Çınarlı " diff --git a/package.json b/package.json index c841377..db31141 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uxrocket.select", - "version": "2.8.0", + "version": "2.8.1", "description": "jQuery based Select box replacement function", "repository": { "type": "git",