I have the following html
<div class="ui-widget" style="margin-top: 1em; font-family: Arial">
Selected:
<div id="locationLog" style="height: 100px; width: 200px; overflow: auto;" class="ui-widget-content"></div>
</div>
<input type="hidden" name="HiddenLocations" id="HiddenLocation" />
I then have some code that runs each time the page loads to add some text into the locationLog
div.
@if (Model.SearchCriteria != null && Model.SearchCriteria.Locations != null)
{
foreach (string t in @Model.SearchCriteria.Locations)
{
<script type="text/javascript">
$("<div/>").text('@t').appendTo("#locationLog");
$("<br/>").text("").appendTo("#locationLog");
$("#locationLog").scrollTop(0);
selectedLocations = $('#locationLog' + ' div').map(function () {
return $(this).text();
}).get();
$('input[name=HiddenLocations]').val(selectedLocations);
</script>
}
}
Now, this code works well when I have text such as 'London' but when I have 'Reykjavík', this get's written as 'Reykjavík
'. How can I write out the correct text?