我正在创建下面的内容,除了一个问题外,它正常:
function showDevices() {
for (var i = 0; i < devices.length; i++) {
var value = devices[i].Value;
var geraete_id = devices[i].Key;
if (value.Name != "") { // if name exists, use that as heading, else, use UDID
$("#geraete-list").append("<li id='geraete-"+i+"'><a href='#'><h5>" + value.Name + "</h5>"
+ "<p>" + value.LastUsedBy + "</p>"
+ "<p id='geraete_DID'>" + geraete_id + "</p>"
+ "<p>Zuletzt Verwendet: " + formatDate(jsonToDate(value.LastUsed)) + "</p></a>"
+ "<a href='#confirm_device_removal' class='deleteListItem' data-rel='dialog'></a></li>");
}
else {
$("#geraete-list").append("<li id='geraete-"+i+"'><a href='#'><h5 id='geraete_DID'>" + geraete_id + "</h5>"
+ "<p>" + value.LastUsedBy + "</p>"
+ "<p>Anonymous User</p>"
+ "<p>Zuletzt Verwendet: " + formatDate(jsonToDate(value.LastUsed)) + "</p></a>"
+ "<a href='#confirm_device_removal' class='deleteListItem' data-rel='dialog'></a></li>");
}
}
$("#geraete-list").listview("refresh");
}
问题是class='deleteListItem'gets
变成了class='deleteListItem ui-btn ui-btn-icon-notext ui-icon-delete'
这是Chrome浏览器的方式还是jQuery Mobile将其添加到我的课程中?
问题是我想运行以下代码,但getDeviceIDforRemoval()
没有做任何事情......
function getDeviceIDforRemoval(){
$(".device_to_remove").text($("#geraete_DID").text()); // sends the device ID into confirm submission dialog
}
function removeDevices(){
var geraetID = $(this).find('span').text(); //retrieves the DID inserted by above function
removeDevice(geraetID,loadDevices);
}
function removeDevice(udid,onSuccess){
Server.removeDevice(udid,onSuccess);
}
答案 0 :(得分:1)
元素可以有多个类,当它们在HTML中显示时,它们显示为
class="class1 class2 class3"
订单在很大程度上并不重要。
此代码......
$(".device_to_remove").text($("#geraete_DID").text());
...将选择类device_to_remove
的所有元素,无论其他类是否也应用于这些元素。然后,它会尝试将这些元素的text
设置为ID为geraete_DID
的元素的文本。
您的哪些元素实际上具有类device_to_remove
?我在你的代码中看不到其他任何引用?