〜在我的文章頁面(http://www.adrtimes.squarespace.com/articles)我的每個條目都是以翻轉時變化的圖像開始的。這工作正常。問題jQuery swapImage();
但是,在我的主頁(http://www.adrtimes.squarespace.com)中,我加載了最近兩篇未歸類爲視頻的文章以及最近被標記爲視頻的兩篇文章。我正在使用jQuery load()從文章頁面獲取內容。除了主頁上的swapImage滾動條之外,一切正常。我試圖將swapImage函數作爲回調函數來使用,但只有一個組或另一個組合會正確地滾動,而不是兩組內容。我不確定是什麼問題!
下面是代碼:
<script type="text/javascript">
<!--
$(function(){
$.swapImage(".swapImage");
/* Homepage */
// load recent articles
$("#LoadRecentArticles").load("/articles/ .list-journal-entry-wrapper .journal-entry-wrapper:not(.category-video)", function(){
//callback...
$("#LoadRecentArticles .journal-entry-wrapper").wrapAll('<div class="list-journal-entry-wrapper" />');
$("#LoadRecentArticles .journal-entry-wrapper:gt(1)").remove();
// modify Read More tag
$('.journal-read-more-tag a:contains(Click to read more ...)').each(function(){
var str = $(this).html();
$(this).html(str.replace('Click to read more ...','Continue reading—'));
});
$.swapImage(".swapImage");
});
// load recent videos
$("#LoadRecentVideos").load("/articles/category/video .list-journal-entry-wrapper", function(){
//callback...
$("#LoadRecentVideos .journal-entry-wrapper:gt(1)").remove();
$('<div class="VideoTag">—video</div>').insertBefore("#LoadRecentVideos .category-video .body img");
// modify Read More tag
$('.journal-read-more-tag a:contains(Click to read more ...)').each(function(){
var str = $(this).html();
$(this).html(str.replace('Click to read more ...','Continue reading—'));
});
$.swapImage(".swapImage");
});
});
-->
</script>
這裏是HTML的在一篇文章條目中的圖像樣本:
<a href="/articles/2010/5/6/article-title-goes-here.html"><img class="swapImage {src: '/storage/post-images/Sample2_color.jpg'}" src="/storage/post-images/Sample2_bw.jpg" /></a>
我不知道該插件的任何(其他比我看了看剛纔),但會不會是它會很困惑,因爲你使用的是完全相同的圖像' src'兩套掉期?你可以嘗試給不想交換的圖像指定一個獨特的名稱,看看是否有幫助? (基本上用新名稱複製圖像。)我可以從Firebug中突出顯示的代碼中看到,當您懸停時,圖像的「src」會發生變化。但它似乎只是給它兩個不起作用的原始'src'。 – user113716 2010-05-20 02:01:40
看來,文章頁面(http://www.adrtimes.squarespace.com)會有相同的問題,如果它是由使用相同的圖像造成的......但我試過了,並設置它,使所有的圖片加載進入主頁都有獨特的名稱 - 但沒有工作。 :( – VUELA 2010-05-20 02:15:52
出於好奇,這是'{src:'/storage/post-images/Sample2_color.jpg'}'由你或插件添加嗎? – user113716 2010-05-20 02:20:22