-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomboxme.js
More file actions
14 lines (14 loc) · 877 Bytes
/
comboxme.js
File metadata and controls
14 lines (14 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$(function () {
$(".bs-searchbox input").blur(function () {
var numberOfActiveItems = $(this).closest(".dropdown-menu").find("li.active").length;
if (numberOfActiveItems > 0) return;
console.log(numberOfActiveItems);
var selectBoxName = $(this).closest(".comboxme").find("select")[0].name;
$("#" + selectBoxName + " option[value='-1']").remove();
$("#" + selectBoxName)
.append('<option value="-1" selected>' + $(this).val() + '</option>')
.selectpicker('refresh');
$("#" + selectBoxName + "_add").remove();
$(this).closest("form").append('<input type="hidden" id="' + selectBoxName + '_add" name="' + selectBoxName + '_add" value="' + $(this).val() + '" />');
});
});