2013-08-07 56 views
1

好了,所以我一直在研究這個了一會兒,重新排序我的誰知道有多少次JavaScript文件。我知道Prototype和jQuery不能很好地與其他人一起工作。但是,我的jQuery工作,但我的jQuery UI功能不是。原型和jQuery UI干擾

我列出我的js文件按以下順序: - 的prototype.js - jquery.js和 - jQuery的ui.js - jQuery的noconflict.js

我的jQuery沒有衝突文件的樣子這個:

jQuery.noConflict(); 

好吧,所有的垃圾都在標籤中。後來在一個頁面上,我這樣做:

<div class="product_tabs clearfix"> 
    <ul> 
     <?php if ($_description): ?> <li><a href="#tabs-1"><?php echo $this->__('Details') ?></a></li> <?php endif; ?> 
     <li><a href="#tabs-2">Review</a></li> 
     <li><a href="#tabs-3">Tags</a></li> 
    </ul> 
    <div class="std clearfix"> 
     <?php if ($_description): ?> <div id="tabs-1"><?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?></div> <?php endif; ?> 
     <div id="tabs-2"> 
      <div class="row"> 
       <div class="span5"><?php echo $this->getChildHtml('review_form') ?></div> 
       <div class="span4"><?php echo $this->getChildHtml('reviews') ?></div> 
      </div> 
     </div> 
     <div id="tabs-3"><?php echo $this->getChildHtml('product_tag_list') ?></div> 
    </div> 
</div> 
<script type="text/javascript"> 
    jQuery(document).ready(function($) { 
     $('.product_tabs').tabs(); 
    }); 
</script> 

這被打破。然而,被稱爲在我noconflict文件我main.js文件,但我的js和原型文件後,用我的工作使用與上述函數相同的ready()來下拉導航。

但是,我動議標籤()函數到main.js文件,並同時從頁面刪除它仍然無法正常工作。有沒有人有任何解決方案?

我抹去這是使用選項卡()函數在頁面上noconflict,它工作正常,但IE8及以下,事實並非如此。所以這不是一個有價值的解決方案......這是我能想到的唯一一個。

而且我必須保持原型,因爲我使用了Magento的CMS!

回答

0

您應該使用$原型功能和jQuery的jQuery的,就像這樣:

<script type="text/javascript"> 
jQuery(document).ready(function() { 
    jQuery('.product_tabs').tabs(); 
}); 
</script> 
+0

哦,我忘了提。我已經嘗試過,但仍然無法正常工作。 jQuery的UI類添加到標籤,但功能是不存在的.. 編輯 - 等等......它的工作。 o.o我的CSS只是沒有被應用。 xD哇......我很喜歡他們看起來並不像他們以前看的樣子,所以甚至沒有測試甚至不能工作。 GEEZ感謝... o.o我很盲目。我嘗試過,太固執,無法檢查。 – Peanut

+0

@Peanut Lol,太棒了 – Thundar

0

請嘗試原型之前最高層即加載jQuery和你的jQuery文件的末尾寫jQuery.noconflict()。然後用jQuery(document).ready(function($){...});初始化您的jQuery代碼。