Ye Iāll go back and follow you as Iām getting confused a bit now, the table build was done by someone else which I think has to stay, and in there you will see the āApplySearchCancelOption()ā which is calling the append function.
$(document).ready(function () {
// #region tblUsers
$('#tblUsers')
.tablesorter({
theme: 'bootstrap',
widthFixed: true,
headerTemplate: '{content} {icon}',
widgets: ['uitheme', 'filter', 'columns', 'zebra'],
widgetOptions: {
filter_external: '#txtSearch',
filter_cssFilter: 'textBox textSizeSmall',
filter_saveFilters: true
},
sortList: [[0, 0]]
})
.tablesorterPager({ container: $('#pager') })
.bind('filterEnd', function (event, data) {
$('#lblCountRecords').text("@LH.GetText(LH.SystemComponent.TheSystem, "lblRecordsCount")" + " " + data.filteredRows);
});
$('#tblUsers td[data-column="0"] > input').attr('data-datatype', "text");
$('#tblUsers td[data-column="1"] > input').attr('data-datatype', "text");
$('#tblUsers td[data-column="2"] > input').attr('data-datatype', "text");
$('#tblUsers td[data-column="3"] > input').attr('data-datatype', "multipleChoiceAnyAll");
ApplySearchCancelOption();
// #endregion
// #region txtSearch
$('#txtSearch').on('input', function () {
tblUsersHighlight();
});
// #endregion
tblUsersPopulate();
});
So with this the span appends when the table is being built.
I can see them, they do append fine, so then this is the rest of the jquery below, to listen etc.
// #region add span to input type search
function ApplySearchCancelOption() {
var input = $("input[type='search']").each(function () {
$(this).parent().append("<span class='clearBtn'>x</span>");
});
}
// #endregion
// #region x clear in input
$(".clearBtn").click(function () {
$(this).prev('.textBox').val('');
$(".clearBtn").hide();
});
// #endregion
// #region show delete x if field typed in
$("input[type='search']").keyup(function () {
//alert("fr");
$("input[type='search']").each(function () {
$(this).next(".clearBtn").show();
if ($(this).val() == "") {
$(this).next(".clearBtn").hide();
}
});
});
$(document).ready(function () {
$("input[type='search']").each(function (index) {
if ($(this).val().length != 0) {
$(this).next(".clearBtn").show();
}
});
});
// #endregion
With the way i currently have it, all the above the checking on refresh now works. But what do yout hink of the way it all is, because I think you are right in that it possibly want know what search box is the one in use etc