I have a simple javascript App, which gives out some information of BLEs.
Everything is working fine, but I have some problems with the JQuery Mobile Library.
I want the whole App in simple JQuery Data-Theme="b". Since the List-View is created dynamically through the addDevice function, it's not working with the JQuery. When I try it without the .append() command, it's working - so there is no problem with my JQuery Mobile Library. I also tried to add the data-theme attribute with the .append() command, with this:
$devices.attr("data-theme" , "b");
but still not working..
Below are the out-takes from my html and javascript files.
html:
<ul data-role="listview" class="devices" id="myresult" data-theme="b"></ul>
<div data-role="content" id="result">
<script type="text/template" id="device">
<ul data-role="listview" data-theme="b">
<li data-address="{0}">
<h2>{1}</h2>
<h2>RSSI: {2}</h2>
</li>
</ul>
</script>
</div>
javascript:
function addDevice(address, name, rssi)
{
for (var i = 1; i<50; i++)
{
var $devices = $(".devices");
var $check = $devices.find("li[data-address='{0}']".format(address));
if ($check.length > 0)
{
return;
}
var template = $("#device").text().format(address, name, rssi);
$devices.append(template);
window.setTimeout(50000);
if (rssi < -90){
alert(name + " loses proximity");
}
}
}
Maybe someone has an idea what's wrong with my code..