Merge branch 'ent-7850-12225-Añadir-buscador-para-agentes-en-wizard-report' into 'develop'

implemented text search of select inputs

See merge request artica/pandorafms!4831
This commit is contained in:
Daniel Rodriguez 2022-06-02 08:31:58 +00:00
commit 8fcdb59ae8
1 changed files with 30 additions and 0 deletions

View File

@ -2027,3 +2027,33 @@ 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());
var regex = new RegExp(search, "gi");
$(select)
.find("option")
.each(function() {
if (
$(this)
.text()
.match(regex) !== null
) {
$(this).show();
} else {
$(this).hide();
}
});
});
};