|
@@ -80,9 +80,6 @@ |
|
|
$dynamicInput.find("input").attr("placeholder", options.dynamicOptLabel);
|
|
|
$ul.append($dynamicInput);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// Cache the dropdown options
|
|
|
var selectOptions = $dropdown.find("li");
|
|
|
|
|
@@ -91,11 +88,10 @@ |
|
|
var $selected;
|
|
|
if ($select.find(":selected").length) {
|
|
|
$selected = $select.find(":selected").last();
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
$selected = $select.find("option, li").first();
|
|
|
- // $selected = $select.find("option").first();
|
|
|
}
|
|
|
+
|
|
|
methods._select($dropdown, $selected);
|
|
|
} else {
|
|
|
var selectors = [], val = $select.val()
|
|
@@ -128,8 +124,6 @@ |
|
|
// On click, set the clicked one as selected
|
|
|
$ul.on("click", "li:not(.dropdownjs-add)", function(e) {
|
|
|
methods._select($dropdown, $(this));
|
|
|
- // trigger change event, if declared on the original selector
|
|
|
- $select.change();
|
|
|
});
|
|
|
$ul.on("keydown", "li:not(.dropdownjs-add)", function(e) {
|
|
|
if (e.which === 27) {
|
|
@@ -141,7 +135,6 @@ |
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
$ul.on("focus", "li:not(.dropdownjs-add)", function() {
|
|
|
if ($select.is(":disabled")) {
|
|
|
return;
|
|
@@ -183,8 +176,7 @@ |
|
|
var $selected;
|
|
|
if ($select.find(":selected").length) {
|
|
|
$selected = $select.find(":selected").last();
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
$selected = $select.find("option, li").first();
|
|
|
}
|
|
|
methods._select($dropdown, $selected);
|
|
@@ -280,10 +272,10 @@ |
|
|
// Toggle option state
|
|
|
$target.toggleClass("selected");
|
|
|
// Toggle selection of the clicked option in native select
|
|
|
- $target.each(function(){
|
|
|
+ $target.each(function() {
|
|
|
var $selected = $select.find("[value=\"" + $(this).attr("value") + "\"]");
|
|
|
$selected.prop("selected", $(this).hasClass("selected"));
|
|
|
- })
|
|
|
+ });
|
|
|
// Add or remove the value from the input
|
|
|
var text = [];
|
|
|
selectOptions.each(function() {
|
|
@@ -298,7 +290,7 @@ |
|
|
if (!multi) {
|
|
|
// Unselect options except the one that will be selected
|
|
|
if ($target.is("li")) {
|
|
|
- selectOptions.not($target).removeClass("selected");
|
|
|
+ selectOptions.not($target).removeClass("selected");
|
|
|
}
|
|
|
// Select the selected option
|
|
|
$target.addClass("selected");
|
|
@@ -317,11 +309,10 @@ |
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Call the callback
|
|
|
- if (this.options.onSelected) {
|
|
|
- this.options.onSelected($target.attr("value"));
|
|
|
- }
|
|
|
-
|
|
|
+ // Call the callback
|
|
|
+ if (this.options.onSelected) {
|
|
|
+ this.options.onSelected($target.attr("value"));
|
|
|
+ }
|
|
|
},
|
|
|
_addOption: function($ul, $this) {
|
|
|
// Create the option
|
|
|
0 comments on commit
2555da7