I have a problem while generating a list of live search results – I put them in a special div with id “result” the way below (dont mind the SightsList, this is an AJAX – pre-retrieved array; also the algorythm is not optimal, I know it, but that’s not the subject). So the main issue is why …
via HTML Language Development » Search Results » ajax:
Dynamic content gets thrown out of a table
I have a problem while generating a list of live search results – I put them in a special div with id “result” the way below (dont mind the SightsList, this is an AJAX – pre-retrieved array; also the algorythm is not optimal, I know it, but that’s not the subject). So the main issue is why table rows get thrown out of a table? Html in browser looks like
- and
- .
$(“input#namebox”).keyup(function()var value = $(this).val();
value = value.toLowerCase();
value = $.trim(value);if (value.length > 3)
$(“#result”).html(“
“);
for (var i=0; i
if (undefined != SightsList[i])
if (void 0 != SightsList[i])SightsList[i] = SightsList[i].toLowerCase();
if (SightsList[i].indexOf(value)+1)
$(“#result”).append(‘
‘ + SightsList[i]+ ‘ – ‘ + ‘ ‘);
$(“#message”).show();
}
}if (i==(SightsList.length-1))
$(“#result”).append(““);
}
//tried to close table here with the same (no) result $(‘.singleresult’).highlight(value);
$(“#result”).show();
}if (value.length < 4)
$(“#result”).hide();
$(“#result”).html(“”);}
…………………………...html and .append aren’t just string functions, they work on the DOM.
$(“#result”).html(““) places a table in the #result element. Since there are no rows specified, it is an empty table (
). Then your .append tries to put a row after that table.
So instead of appending to the contents of #result, you want to append to the table you are creating:
$(“#result > table”).append(‘‘ + SightsList[i]+ ‘ ‘ + ‘ ‘);and remove your attempt to add an end-table tag.
For more info: Dynamic content gets thrown out of a table
HTML Language Development » Search Results » ajax
Dynamic content gets thrown out of a table
© AutoHotKey. All rights reserved.
NIF B76271691