2012-04-30 52 views
0

我想知道是否有人能夠幫助我請。fancyBox和jQuery刪除工具衝突

我已經把它創建this圖片庫頁面的腳本。我正在使用'fancyBox'來創建幻燈片和一個jQuery的演示源於我已經適應提供刪除功能​​。

我身邊的我的這幾行代碼就是問題所在:

<ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix"> 

     <?php for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) : 
          $xmlFile = $descriptions->documentElement->childNodes->item($i); 
          $name = htmlentities($xmlFile->getAttribute('originalname'), ENT_COMPAT, 'UTF-8'); 
          $description = htmlentities($xmlFile->getAttribute('description'), ENT_COMPAT, 'UTF-8'); 
          $source = $galleryPath . rawurlencode($xmlFile->getAttribute('source')); 
          $thumbnail = $thumbnailsPath . rawurlencode($xmlFile->getAttribute('thumbnail')); 
        ?> 

        <li class="ui-widget-content ui-corner-tr"> 
     <a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>"alt="<?php echo $description; ?>" width="96" height="72"/> </a><a href="link/to/trash/script/when/we/have/js/off" title="Delete this image" class="ui-icon ui-icon-trash">Delete image</a> 
     <?php endfor; ?> 
     </li> 
     </ul> 

連同這些線:<ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix"><li class="ui-widget-content ui-corner-tr">及其各自的結束標記時,「的fancybox」功能不起作用。沒有他們,它工作正常。

我是比較新的jQuery和我一直在工作的這幾天和我似乎無法找到解決的辦法。

我只是想知道一個人是否有可能看這個,請讓我知道我要去哪裏錯了。

佛的其他信息,我已經添加了下面的「的fancybox」腳本。

<script type="text/javascript"> 

      $('.fancybox').fancybox({ 
       openEffect : 'elastic', 
       closeEffect : 'elastic', 

       padding : 20, 
       fitToView : true, 

       prevEffect : 'none', 
       nextEffect : 'none', 

       closeBtn : false, 
       arrows : false, 

       helpers : { 
        title : { 
         type : 'inside' 
        }, 
        buttons : {} 
       }, 

       afterLoad : function() { 
        this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : ''); 
       } 
      }); 


</script> 

許多的感謝和親切的問候

回答

0

只爲任何人在未來有這個問題:

畫廊有從jQuery UI的一個display:none集例。

根本解決這一行:

<ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix"> 


<ul id="gallery" class="ui-helper-reset ui-helper-clearfix"> 
0

也許你需要在此之前把​​</li>後。

介紹如何寫的初始化的fancybox腳本

+0

你好,非常感謝幫助我與此有關。我已經按照你的建議改變了上面兩行,但不幸的是,問題仍然存在。我已將'fancyBox'腳本添加到我的原始帖子中,我希望這是您的需要。請,如果有什麼你需要的,不要猶豫,問。親切的問候 – IRHM

0

你刪除工具使用此功能

// resolve the icons behavior with event delegation 
$("ul.gallery > li").click(function(event) { 
var $item = $(this), 
$target = $(event.target); 
if ($target.is("a.ui-icon-trash")) { 
    deleteImage($item); 
} else if ($target.is("a.ui-icon-zoomin")) { 
    viewLargerImage($target); 
} else if ($target.is("a.ui-icon-refresh")) { 
    recycleImage($item); 
} 
return false; 
}); 

所以這是防止必然的fancybox子元素<a class="fancybox">任何行動。

也許你可以添加另一個條件繞過return false如果$taget.is("a.fancybox"),如:

// resolve the icons behavior with event delegation 
$("ul.gallery > li").click(function(event) { 
var $item = $(this), 
$target = $(event.target); 
if ($target.is("a.ui-icon-trash")) { 
    deleteImage($item); 
} else if ($target.is("a.ui-icon-zoomin")) { 
    viewLargerImage($target); 
} else if ($target.is("a.ui-icon-refresh")) { 
    recycleImage($item); 
} else if ($target.is("a.fancybox")) { 
    // do nothing and let fancybox to play 
} else { 
    return false; 
} 
}); 
+0

嗨,真誠的感謝您花時間回覆我的文章和幫助。我對JavaScript比較陌生,所以請隨時向我坦白。我試過了你的建議代碼,並在第151行添加了一個'})',因爲我收到了一個錯誤。雖然我可以刪除圖像,但我無法使'fancyBox'工作。我已經通過Firefox執行了此操作,並且沒有顯示任何錯誤,所以我不確定錯誤在哪裏。我已更新與原始帖子中鏈接相關的頁面,以顯示新代碼。我只是想知道你是否可以看看這個問題,讓我知道我哪裏出了問題。親切的問候 – IRHM

+0

我沒有看到這個'else if($ target.is(「a。fancybox「))'在您的網頁/腳本 – JFK

+0

嗨@JFK,非常感謝您繼續幫助我,並對錯誤表示真誠的歉意,這是一個剪切和粘貼錯誤。我現在修改了代碼以包含此'fancybox'功能現在正在運行,但不幸的是我無法刪除任何圖像,我收到一個'Error 404 not found'消息,我通過firefox運行了這個,除了404消息外,它沒有提供錯誤的更多細節| Kind kind – IRHM