Skip to content

Commit

Permalink
Merge pull request #9 from uxrocket/2.x
Browse files Browse the repository at this point in the history
2.x
  • Loading branch information
bcinarli committed Sep 16, 2015
2 parents bc4ba51 + c23b15f commit 814e149
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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ı <[email protected]>"
Expand Down
24 changes: 17 additions & 7 deletions lib/uxrocket.select.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
}

$el.after(
'<span class="' + ns.current + ' ' + _opts.current + '">' +
'<span class="' + ns.current + ' ' + ns.current + '-' + _opts.index + ' ' + _opts.current + '">' +
' <span class="' + ns.text + '">' + $current + '</span>' +
' <span class="' + ns.arrow + ' ' + _opts.arrow + '"></span>' +
'</span>');
Expand Down Expand Up @@ -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();
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -349,7 +359,7 @@
};

// Version
ux.version = "2.8.0";
ux.version = "2.8.1";

// settings
ux.settings = defaults;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 814e149

Please sign in to comment.