I'm trying to use the FLIP! plugin and have it's content loaded by ajax. I'm running into a problem though. It's just not working.
I can see the post event happening in firebug but nothing seems to change when I populate the "content" parameter inside the FLIP! plug in.
Below is my code which may explain things better.
<script type="text/javascript">
function getFlipContent(url,command, target){
$.post(url, {"data": command}, function(response) {
console.log(response);
//return response; // this is not working
replaceHtml(target,response); // workaround but kinda not really
});
}
function replaceHtml(object,html){
$(object).html();
$(object).html(html);
}
$(function(){
$(".flipable2").bind("click", function() {
var url= $(this).data("url");
var command= $(this).data("command");
var target = $(this).data("target");
//alert(flip);
if (target === undefined) {
flip = "self";
}
if (target == "self") {
$($(this)).flip({
direction: 'lr',
color: '#ffffff',
content: function() {
getFlipContent(url, command, target);
}
});
return false;
}
else {
$(target).flip({
direction: 'lr',
color: '#ffffff',
content: function() {
getFlipContent(url, command, target);
}
});
return false;
}
});
});
</script>
<body>
<div id="header">
<table width="100%" cellpadding="0px" border="0px" cellspacing="0px">
<tr>
<td><a href="#" class="flipable2 box" data-target="#page" data-url="test.php" data-command="test">FLIP</a></td>
</tr>
</table>
</div>
<div id="page" class="box">
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH</td>
</div>
SO right now I'm using a replachtml function to manually re-write the contents of the target I just "flipped". This sorta works but breaks the animation so I really would rather use the plugin's content parameter... When I do that though it just doesn't do anything. The animation completes but there is no content change. I think perhaps I am missing something. Any help would be welcome.
Here is a jsfiddle too: http://jsfiddle.net/mUhuN/9/ though I wasn't sure how to fake an ajax request.
Anyway please help :)
Try to use the callbacks to load Ajax before the animation: