Permalink
Browse files

Disabled functionality added

1 parent c22c969 commit b6eb485791dd6a681add5338535ea2e1362bcf6d @corientdev corientdev committed Feb 17, 2017
Showing with 12 additions and 0 deletions.
  1. +12 −0 jquery.dropdown.js
View
@@ -264,6 +264,9 @@
// Close opened dropdowns
$(".dropdownjs > ul > li").attr("tabindex", -1);
+ if (e.target.getAttribute('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.attr("disabled")) {
+ return;
+ }
// Unselect options except the one that will be selected
if ($target.is("li")) {
selectOptions.not($target).removeClass("selected");
@@ -384,6 +391,11 @@
$option.addClass("selected");
}
+ if ($this.prop("disabled")) {
+ $option.attr("disabled", true);
+ $option.addClass("disabled");
+ }
+
// Append option to our dropdown
if ($ul.find(".dropdownjs-add").length) {
$ul.find(".dropdownjs-add").before($option);

0 comments on commit b6eb485

Please sign in to comment.