<html>
<h1>animationComplete</h1>
<div class="red">
<div id="tile1" class="live-tile" data-initdelay="4500" data-delay="2500" data-mode="flip">
<div><p>This will be replaced with items from the hidden <ul> with the class 'itemsSource'
<span class="tile-title">First Tile</span>
</p>
</div>
<div>
<p>
item content will be here
</p>
</div>
</div>
<!-- im using a ul here, but this pattern can be used with div, p, span etc. -->
<ul class="itemsSource">
<li>Some content to use 1</li>
<li>Some content with a title to use 2
<span class="tile-title">look a title!</span>
</li>
<li><p>Some content in a <p> to use 3</p></li>
<li>Some content to use 4</li>
<li>Some Content to use 5</li>
</ul>
</div>
</html>
<script>
var $item = $(".itemsSource>li").first();
//set the back tile to have content of the first item by default
$("#tile1>div").last().html($item.html());
//set up tile
$("#tile1").liveTile({
pauseOnHover: true,
animationComplete: function(tileData, $front, $back) {
//get the next item from the list or the first
$item = $item.next("li");
if ($item.length == 0)
$item = $(".itemsSource>li").first();
$back.html($item.html());
}
});
</script>
我正在尝试使用Json从数据库中获取所有记录。对于每个记录,“#tile1”div是动态添加的,包含记录的数据。我想调用每个tile的函数来加载和访问列表中包含的详细信息。可以帮助如何调用每个div的函数
这是我为每条记录动态创建磁贴的代码 点击here查看平铺动画
function showMessages(profiles) {
for (var i = 0; i < profiles.length; i++) {
var message = profiles.offers[i];
$('div.red').append(
$('<div/>')
.attr({
id: message.username,
class: "live-tile",
mode: "flip"
}).append($('<div/>').append($('<p/>').text(message.user.email))
.append($('<span/>').attr({
class: "tile-title"
}).text(message.username))));
$("div#" + (message.username)).append(($("<div/>").append($("<p/>"))));
var list = $("div#" + (message.username)).append($('<ul/>').attr({
class: "itemsSource"
})).find('ul');
list.append(($("<li/>").text(message.full_name)));
list.append(($("<li/>").text(message.mobile)));
list.append(($("<li/>").text(message.currentcity)));
}
loadtile();
}