Reputation: 1432
With respect to the above fiddle how could I use different links in block 1 to load up an external file (txt, HTML) in block 2 before it slides into view? I know that JQuery.load() will be part of the process
$(".block2").load("helloworld.txt");
Upvotes: 1
Views: 143
Reputation: 2274
This should work - Provide your animate as a complete callback to the .load() function.
$(function() {
$(".link1").click(function() {
$.load("url/to/load/from", function() {
//Insert contents of file wherever
$(".block1").stop(true, true).animate({ left: -400 }, 200);
$(".block2").stop(true, true).animate({ left: 25 }, 200);
});
});
$(".link2").click(function() {
$.load("url/to/load/from", function() {
//Insert contents of file wherever
$(".block2").stop(true, true).animate({ left: 450 }, 200);
$(".block1").stop(true, true).animate({ left: 25 }, 200);
});
});
});
Upvotes: 1