Permalink
Browse files

Merge pull request #59 from corientdev/master

Disabled functionality added
2 parents cf7d54b + 71267a7 commit 5583fb6fbc9af7369e10bc9b67236a42d38e753d @FezVrasta committed on GitHub Feb 20, 2017
Showing with 12 additions and 1 deletion.
  1. +12 −1 jquery.dropdown.js
View
@@ -180,7 +180,7 @@
});
$select.on("DOMNodeRemoved", function(e) {
- var deletedValue = e.target.getAttribute('value');
+ var deletedValue = $(e.target).attr('value');
$ul.find("li[value='"+deletedValue+"']").remove();
var $selected;
@@ -264,6 +264,9 @@
// Close opened dropdowns
$(".dropdownjs > ul > li").attr("tabindex", -1);
+ if ($(e.target).hasClass('disabled')) {
+ return;
+ }
$input.removeClass("focus");
});
}
@@ -292,6 +295,7 @@
methods._select($(this), $target);
},
_select: function($dropdown, $target) {
+
if ($target.is(".dropdownjs-add")) return;
// Get dropdown's elements
@@ -324,6 +328,9 @@
// Behavior for single select
if (!multi) {
+ if ($target.hasClass("disabled")) {
+ return;
+ }
// Unselect options except the one that will be selected
if ($target.is("li")) {
selectOptions.not($target).removeClass("selected");
@@ -384,6 +391,10 @@
$option.addClass("selected");
}
+ if ($this.prop("disabled")) {
+ $option.addClass("disabled");
+ }
+
// Append option to our dropdown
if ($ul.find(".dropdownjs-add").length) {
$ul.find(".dropdownjs-add").before($option);

0 comments on commit 5583fb6

Please sign in to comment.