0
我使用this brilliant solution來顯示作爲POST請求結果的fancybox。jQuery使用ajax調用定製fancybox
問題是我不知道如何自定義fancybox行爲。
如何在執行ajax時顯示旋轉動畫(或類似)?
如何設置標題/顯示fancybox的內容爲(風格化)html?
我使用this brilliant solution來顯示作爲POST請求結果的fancybox。jQuery使用ajax調用定製fancybox
問題是我不知道如何自定義fancybox行爲。
如何在執行ajax時顯示旋轉動畫(或類似)?
如何設置標題/顯示fancybox的內容爲(風格化)html?
function formatTitle(title, currentArray, currentIndex, currentOpts) {
return '<div id="tip7-title"><span><a
href="javascript:;"onclick="$.fancybox.close();"><img src="/data/closelabel.gif" />
</a></span>' + (title && title.length ? '<b>' + title + '</b>' : '') + 'Image ' +
(currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}
function showResponse(responseText){
//first of all hide the spinning animation div
//then process the response as you like
$.fancybox({
'content' : responseText,
'titlePosition' : 'inside',
'titleFormat' : formatTitle
});
}
function showspinningAnimation(iddiv_container){
//this function is called before the ajax call
//put your animation spinning or whatever in a div
}
var options = {
beforeSubmit: showRequest, // pre-submit callback
success: showResponse
};
$(document).ready(function() {
$("#myForm").ajaxForm(options);
});
解釋:
formatTitle:此函數格式的標題爲您的fancybox showspinningAnimation:在這個函數在一個div放在一個旋轉.gif要點(爲例),顯示加載...