mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
implemented text search of select inputs
This commit is contained in:
parent
b2ea3d1d7a
commit
0223dd27c7
@ -2029,3 +2029,32 @@ function inArray(needle, haystack) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter selector item by text based on a text input.
|
||||||
|
*
|
||||||
|
* @param {string} textbox Text input.
|
||||||
|
*
|
||||||
|
* @return {void}
|
||||||
|
*/
|
||||||
|
$.fn.filterByText = function(textbox) {
|
||||||
|
var select = this;
|
||||||
|
|
||||||
|
$(textbox).bind("change keyup", function() {
|
||||||
|
var search = $.trim($(textbox).val());
|
||||||
|
|
||||||
|
$(select)
|
||||||
|
.find("option")
|
||||||
|
.each(function() {
|
||||||
|
if (
|
||||||
|
$(this)
|
||||||
|
.text()
|
||||||
|
.includes(search.toLowerCase()) === true
|
||||||
|
) {
|
||||||
|
$(this).show();
|
||||||
|
} else {
|
||||||
|
$(this).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user