JSFiddle - React, Tailwind, and code Playground
by Md. Atiquzzaman Soikat
JavaScript
$(document).ready(function(e) {
function initAutocomplete {
var garshunivalue = 0;
if ($('#True').val() == "true") {
if ($('#defaultgarshuniid').val() > 0) {
garshunivalue = $('#defaultgarshuniid').val();
}
}
$("#qoloname").autocomplete({
source: LiveUrl + "/api/Qolo/QoloList?garshunivalue=" + garshunivalue,
select: function(event, ui) {
$("#qoloname").val(ui.item.Qolo_Name);
var searchtype1;
if (typeof $('input[name=radio-choice-t-6]:checked').val() == "undefined") {
searchtype1 = 'qolo';
} else {
searchtype1 = $('input[name=radio-choice-t-6]:checked').val();
}
window.location.href = "index.html?term=" + ui.item.Qolo_Name + "&type=" + searchtype1;
},
minLength: 0,
close: function() {
$(this).blur();
}
}).focus(function(event, ui) {
$(this).autocomplete("#stanza", "");
});
$.ui.autocomplete.prototype._renderItem = function(ul, item) {
var re = new RegExp($.trim(this.term.toLowerCase()));
var qoloname = item.Qolo_Name.replace(re, "<span style='font-weight:600;color:#5C5C5C;'>" + $.trim(this.term.toLowerCase()) + "</span>");
var garshuniname = item.Garshuni_Name.replace(re, "<span style='font-weight:600;color:#5C5C5C;'>" + $.trim(this.term.toLowerCase()) + "</span>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + "<div style='float:right;'>" + qoloname + "</div>" + "<div style='float:left;'>" + garshuniname + "</div>" + "</a>")
.appendTo(ul);
};
}
$(".qololbl").click(initAutocomplete);
initAutocomplete();
//should also work
//$(".qololbl").trigger('click)
});