我认为我的 jquery ajax 页面加载有点慢。当我使用 onClick 处理程序单击我的 href 时,有时它没有响应,我必须双击?我怎样才能避免这种情况?
<a target="_blank" class="arrow" href="javascript:void();"
onclick="f(\"value",\"value\");return false;">
<div class="teaser">
<h3></h3>
<p class="subheadline"></p>
<hr class="divider">
<p></p>
</div>
<img height="353" class="img" src="example.jpg" width="374">
</a>
也许是因为 empy h3 和 p 标签?感觉有点迟钝??
我的函数 f 是:
function f (url, id)
{
var btn = $(this);
if (btn.data('running'))
return;
$j('#tx #singleview').empty();
btn.data('running', true);
url="http://"+url+"index.php?id="+id+"&eID=tx";
url_stack.push(url);
$j.getJSON(url, function(json) {
$('#container').css({
"z-index" : "-100",
"margin-left" : "148",
"top" : "-800"
})
$('#container').animate({
"opacity": "0.0",
"top": '+=800'
}, 900, function() {
// Animation complete.
});
var singleview = $j('#tx #singleview');
singleview.css({
"position": "relative",
"top": "-800px",
"height": "800px"
})
singleview.append($j("#singleviewTemplate").tmpl(json).css({
"visibility": "visible",
"position": "relative"
}));
singleview.animate({
opacity: 100.0,
top: 0
}, 900, function() {
// Unset it here, this lets the button be clickable again
btn.data('running', false);
});
});
}