javascript - jquery design after dynamically loading -
i have simple javascript app, gives out information of bles.
everything working fine, have problems jquery mobile library.
i want whole app in simple jquery data-theme="b". since list-view created dynamically through adddevice function, it's not working jquery. when try without .append() command, it's working - there no problem jquery mobile library. tried add data-theme attribute .append() command, this:
$devices.attr("data-theme" , "b");
but still not working..
below out-takes html , 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) { (var = 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 has idea what's wrong code..
i don't know want achieve here. can dynamically append data in listview in jquery mobile using below code.
html:
<div data-role="content"> <ul data-role="listview" class="devices" id="myresult" data-theme="b"> </ul> </div>
javascript : in simple , easy way.
function adddevice(address,name,rssi) { var result =""; (int = 1; i<50;i++) { result += '<li>'+address+'<h2> '+name+'</h2>' result +='<h2> rssi : '+rssi+'</h2>' result +='</li>' } $('#myresult').append(result); }
as can check below link dynamic list using jquery mobile. http://jsfiddle.net/gajotres/8uac7/
Comments
Post a Comment