リンクがクリックされたときに、jqueryajaxを使用して別のページをモーダルウィンドウにロードしています。モーダルコンテンツの読み込み中に、表示される読み込み画像があります。読み込み中の画像はページのdivにあり、ページに読み込み中のajaxに対して表示されます。これはすべて正しく機能しますが、ajax呼び出しが成功した後、画像を非表示にできないようです。
これが私が使用しているjqueryです:
$('#loadingImage').ajaxStart(function(){
$(this).show();
});
$('#loadingImage').ajaxSuccess(function(){ //also tried ajaxStop
$(this).hide();
});
function loadMap(){
$('#whereweare-map').click(function(){
$('#lightBox').removeClass().addClass('reveal-modal expand');
$.ajax({
url: '/Map#mapLoad',
success: function(data){
$('#lightBox').reveal();
$('#lightBoxContent').html(data);
}
});
return false;
});
}
loadMap();
HTML:
<div id="imageLoading"></div>
<a href="#" id="whereweare-map">Where We Are</a>
<div class="reveal-modal" id="lightBox">
<div id="lightBoxContent"><!-- Load Content Here --></div>
<a class="close-reveal-modal">×</a>
</div>
そしてCSS:
#loadingImage {
display:none;
height:84px;
width:84px;
position:fixed;
top:50%;
left:50%;
z-index: 1;
background: url('preloader.gif') no-repeat center center;
background-color: #000;
background-color: rgba(0, 0, 0, 0.7);
-moz-border-radius:45px;
-webkit-border-radius:45px;
border-radius:45px;
}
助けてくれてありがとう。