Magento 1.9.1 CEを使用すると、levatezoomは製品ページでは機能しません(アキャビのTypeError:Undefinedは関数ではありません)
-
12-12-2019 - |
質問
だから、マイマゼントの「製品表示」ページの製品サムネイルをクリックしたときに、サムネイルをクリックすると(代わりに上にスクロールします)。これは私がコンソールに入るエラーです:
Chrome: Uncaught TypeError: undefined is not a function
Firefox: TypeError: image.elevateZoom is not a function
.
RWD / DEFAULT / JS / APP.JSの行1194:
.
image.elevateZoom();
これが機能していない理由はなぜですか?私のテーマが行く限り、それはMagento 1.9.1のRWDテーマに大きく戻ってきた非常に最小限のテーマです。私は reada anda>を使用しています。それがうまくいくかどうかを確認する...ダイスなし。
解決
解決策を見つけました!
私は最初にカスタム.jsファイルを作成することによって@ Aredubyaのソリューションを試みました jQuery.noconflict();
とでlocal.xmlに含めるようにしてください
.
<catalog_product_view>
<reference name="head">
<action method="addItem"><type>skin_js</type><script>js/lib/elevatezoom/jquery.elevateZoom-3.0.8.min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/mynoconflict.js</script></action>
</reference>
</catalog_product_view>
Chromeの開発者コンソールの表示源に、jQuery.elevatezoom-3.0.8.min.js の直後にロードされているカスタムJSファイルがロードされていました
Chromeを通して見るMagentoがProtoypeとjQueryをロードした後に含まれているnoconflict.jsにつまずいた。
溶液
.
// Avoid PrototypeJS conflicts, assign jQuery to $j instead of $
var $j = jQuery.noConflict();
助けてくれてありがとう!
他のヒント
すべてのビューファイルで正しく適用されていると仮定すると、jQuery.elevatezoom-3.0.8.min.jsがまだ読み込まれます。テーマが使用する他のJSライブラリに応じて、 jquery.noconflict()も。
下部へのインポート:
<reference name="head">
<action method="addJs"><script>varien/product.js</script></action>
<action method="addJs"><script>varien/configurable.js</script></action>
<action method="addItem"><type>skin_js</type>
...
... other imports here
...
<action method="addItem"><type>skin_js</type><script>js/lib/elevatezoom/jquery.elevateZoom-3.0.8.min.js</script></action>
</reference>
.
jQuery.noconflict のメモ
すでにNoconflictセットアップを持っていて、まだ問題を実行している人のためにgithub で上昇したチケット
// First call elevateZoom
$j(document).ready(function() {
$j('.product-image-thumbs').attr('id', 'zoomGallery');
//initiate the plugin and pass the id of the div containing gallery images
$j("#image-main").elevateZoom({gallery:'zoomGallery', cursor: 'pointer', galleryActiveClass: 'active', imageCrossfade: true, loadingIcon: 'http://www.elevateweb.co.uk/spinner.gif'});
//pass the images to Fancybox
$j("#image-main").bind("click", function(e) {
var ez = $j('#image-main').data('elevateZoom');
$j.fancybox(ez.getGalleryList());
return false;
});
// after click you need to remove the current zoom
$j(".product-image-thumbs li img").click(function(){
$j("#image-main").attr("src", $j(this).attr("data-main-image-src"));
$j('.zoomContainer').remove();
$j('#image-main').removeData('elevateZoom');
// and then call it again
$j('#image-main').elevateZoom({
gallery: 'more-vies',
lensSize: 200,
cursor: 'pointer',
galleryActiveClass: 'active',
imageCrossfade: true,
scrollZoom : true,
responsive: true
});
});
});
.