Hi,
I have a click event that animates in some AJAX content onto a page.
Once this content has been revealed and a user clicks the same link that activated the process i now want to reverse the process and close the currently open fly out content.
At the moment the currently open fly out is closed either by clicking a 'close' link or clicking another fly out link in the sequence. If a user clicks the current fly out link then i want the current fly out to close.
// Close fly out function
function closeFlyout() {
$('.fly_container').animate({
'right': '-332'
}, 300, 'swing', function() {
$(this).detach();
/* TODO: z-index issues in IE7, IE6
$('.dark_overlay').fadeOut(300, function() {
$(this).remove();
});
*/
});
};
$('.widget').delegate('.widget .fly_out', 'click', function() {
/*
TODO: z-index issues in IE7, IE6
$('body').prepend('<div class="dark_overlay" />');
*/
var $widget = $(this).closest('.widget');
var $flyOutIndex = $(this).index('.fly_out');
if ($flyOutIndex == 0) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/Priceassessment/product_order.htm';
} else if ($flyOutIndex == 1) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_comparisons.htm';
} else if ($flyOutIndex == 2) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_scenarios.htm';
} else if ($flyOutIndex == 3) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_analysis.htm';
}
$('.current').removeClass('current');
$(this).addClass('current');
// Close any open flyouts
closeFlyout();
$.ajax({
type: 'GET',
url: DashboardApplicationRoot + $flyOutURL,
dataType: 'html',
cache: true,
success: function(data) {
$($widget).prepend(data);
$('.fly_container').animate({ 'right': '0' }, 300);
$('.scroll').jScrollPane();
$('.striped li:nth-child(even)').addClass('odd');
}
});
return false;
});
// Close fly out function
$('.widget').delegate('.fly_container .close', 'click', function() {
closeFlyout();
$('.current').removeClass('current');
return false;
});