我使用带有html attr的甜蜜警报库,但我需要在swal
中显示循环中的一些值,我得到的只是[object object]
我不知道为什么。
这是我的代码:
$(".track_details").click(function () {
var data = $(this).data('val');
swal({
title: "HTML <small>Title</small>!",
text: "<div class='row'>\
<div class='col-md-2'>\
<strong>\
<span>Message</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>Status</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>Datetime</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>City</span>\
</strong>\
</div>\
<div class='col-md-1'>\
<strong>\
<span>State</span>\
</strong>\
</div>\
<div class='col-md-1'>\
<strong>\
<span>Zip</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>Country</span>\
</strong>\
</div>\
</div> <div class='row my_tracking_swal'></div> \
" + $.each(data, function (index, val) {
$("<div class='col-md-2'>\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
<div class='col-md-2'>\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
<div class='col-md-1'>\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
<div class='col-md-1'>\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
<div class='col-md-2' >\
<strong>\
<span>" + val.tracking_status + "</span>\
</strong>\
</div>\
").appendTo(".my_tracking_swal");
}),
html: true
}) ;
});
我的数据值看起来像[{'tracking_status':'value'},{'tracking_status':'value'},{'tracking_status':'value'}]