0

回転スライダーとタブ スクリプトを含むページを作成しようとしています。

ここでページを見つけることができます: http://lovebomb.nl/dating

しかし、どういうわけか、スクリプトは互いに競合しています。

回転スライダーのこの部分:

        var tpj=jQuery;
    tpj.noConflict();

    tpj(document).ready(function() {

    if (tpj.fn.cssOriginal!=undefined)
        tpj.fn.css = tpj.fn.cssOriginal;

        tpj('.fullwidthbanner').revolution(
            {
                delay:9000,
                startwidth:1024,
                startheight:616,
                onHoverStop:"on",                       // Stop Banner Timet at Hover on Slide on/off
                thumbWidth:100,                         // Thumb With and Height and Amount (only if navigation Tyope set to thumb !)
                thumbHeight:50,
                thumbAmount:3,
                navigationStyle:"round",                // round,square,navbar,round-old,square-old,navbar-old, or any from the list in the docu (choose between 50+ different item), custom
                navigationHAlign:"center",              // Vertical Align top,center,bottom
                navigationVAlign:"top",                 // Horizontal Align left,center,right
                navigationHOffset:0,    
                navigationVOffset:20,
                soloArrowLeftHalign:"left",
                soloArrowLeftValign:"center",
                soloArrowLeftHOffset:20,
                soloArrowLeftVOffset:0,
                soloArrowRightHalign:"right",
                soloArrowRightValign:"center",
                soloArrowRightHOffset:20,
                soloArrowRightVOffset:0,
                touchenabled:"off",                     // Enable Swipe Function : on/off
                stopAtSlide:1,                          // Stop Timer if Slide "x" has been Reached. If stopAfterLoops set to 0, then it stops already in the first Loop at slide X which defined. -1 means do not stop at any slide. stopAfterLoops has no sinn in this case.
                stopAfterLoops:0,                       // Stop Timer if All slides has been played "x" times. IT will stop at THe slide which is defined via stopAtSlide:x, if set to -1 slide never stop automatic
                hideCaptionAtLimit:0,                   // It Defines if a caption should be shown under a Screen Resolution ( Basod on The Width of Browser)
                hideAllCaptionAtLilmit:0,               // Hide all The Captions if Width of Browser is less then this value
                hideSliderAtLimit:0,                    // Hide the whole slider, and stop also functions if Width of Browser is less than this value
                fullWidth:"on",
                shadow:0                                //0 = no Shadow, 1,2,3 = 3 Different Art of Shadows -  (No Shadow in Fullwidth Version !)
            });
 });

タブスクリプトのこの部分と競合しているようです:

$(document).ready(function(){
$('#tabs div').hide();
$('#tabs div:first').show();
$('#tabs ul li:first').addClass('active');
$('#tabs ul li a').click(function(){ 
$('#tabs ul li').removeClass('active');
$(this).parent().addClass('active'); 
var currentTab = $(this).attr('href'); 
$('#tabs div').hide();
$(currentTab).show();
return false;
});
});

これらのスクリプトは、次の場所にある 1 つの JS ファイルにまとめられています: http://lovebomb.nl/dating/tabs.js

このサイトをタブ スクリプトのベースとして使用しました: http://www.snelgeldonlineverdienen.nl/

唯一の違いは、jquery と jquery UI のバージョンです。このページのバージョンの jquery を使用すると、回転スライダーが機能しなくなります。

私はすでに約4時間タブを修正しようとしています.

本当に助けが必要です。

前もって感謝します :)

ルーク

4

3 に答える 3

2

tabs.jsの先頭には、次の宣言があります。

var tpj=jQuery;
tpj.noConflict();

これは、変数tpjjQueryオブジェクトに設定し、jQuery をnoConflict()に入れます。

「多くの JavaScript ライブラリは、jQuery と同様に$を関数または変数名として使用します。jQuery の場合、$ は jQuery の単なるエイリアスであるため、すべての機能は$を使用しなくても利用できます。jQuery と一緒に別の JavaScript ライブラリを使用する必要がある場合は、$.noConflict()を呼び出して、 $の制御を他のライブラリに戻します。"

jQuery が非競合モードになったので、$を使用して jQuery にアクセスすることはできなくなりました。したがって、tab.js の下部にあるコードを実行すると、次のようになります。

$(document).ready(function(){
    $('#tabs div').hide();
    $('#tabs div:first').show();
    $('#tabs ul li:first').addClass('active');
    $('#tabs ul li a').click(function(){ 
    $('#tabs ul li').removeClass('active');
    $(this).parent().addClass('active'); 
    var currentTab = $(this).attr('href'); 
    $('#tabs div').hide();
    $(currentTab).show();
        return false;
    });
});

エラーが発生します

「キャッチされていない TypeError: オブジェクト [オブジェクト オブジェクト] のプロパティ '$' は関数ではありません」

because $ no longer references jQuery. To access jQuery we must use jQuery or tpj

if we alter the tabs.js changing $ to either jQuery or tpj

tpj(document).ready(function(){
    tpj('#tabs div').hide();
    tpj('#tabs div:first').show();
    tpj('#tabs ul li:first').addClass('active');
    tpj('#tabs ul li a').click(function(){ 
    tpj('#tabs ul li').removeClass('active');
    tpj(this).parent().addClass('active'); 
    var currentTab = tpj(this).attr('href'); 
    tpj('#tabs div').hide();
    tpj(currentTab).show();
        return false;
    });
});

the code should execute correctly.

于 2013-04-17T19:07:55.167 に答える
0

最新の jQuery ライブラリ バージョン (1.7.1 +) を使用し、上記のコードを次のように変更して、両方を init.js 内の単一のファイルに結合し、ページに含まれるすべての *.js ファイルの下部に配置してみてください。

   jQuery(document).ready(function() {
       if (jQuery.fn.cssOriginal!=undefined)
         jQuery.fn.css = jQuery.fn.cssOriginal;
           jQuery('.fullwidthbanner').revolution({

            delay:9000,
            startwidth:1024,
            startheight:616,
            onHoverStop:"on",        // Stop Banner Timet at Hover on Slide on/off
            thumbWidth:100,        // Thumb With and Height and Amount (only if navigation Tyope set to thumb !)
            thumbHeight:50,
            thumbAmount:3,
            navigationStyle:"round",   // round,square,navbar,round-old,square-old,navbar-old, or any from the list in the docu (choose between 50+ different item), custom
            navigationHAlign:"center",              // Vertical Align top,center,bottom
            navigationVAlign:"top",                 // Horizontal Align left,center,right
            navigationHOffset:0,    
            navigationVOffset:20,
            soloArrowLeftHalign:"left",
            soloArrowLeftValign:"center",
            soloArrowLeftHOffset:20,
            soloArrowLeftVOffset:0,
            soloArrowRightHalign:"right",
            soloArrowRightValign:"center",
            soloArrowRightHOffset:20,
            soloArrowRightVOffset:0,
            touchenabled:"off",                     // Enable Swipe Function : on/off
            stopAtSlide:1,                          // Stop Timer if Slide "x" has been Reached. If stopAfterLoops set to 0, then it stops already in the first Loop at slide X which defined. -1 means do not stop at any slide. stopAfterLoops has no sinn in this case.
            stopAfterLoops:0,                       // Stop Timer if All slides has been played "x" times. IT will stop at THe slide which is defined via stopAtSlide:x, if set to -1 slide never stop automatic
            hideCaptionAtLimit:0,                   // It Defines if a caption should be shown under a Screen Resolution ( Basod on The Width of Browser)
            hideAllCaptionAtLilmit:0,               // Hide all The Captions if Width of Browser is less then this value
            hideSliderAtLimit:0,                    // Hide the whole slider, and stop also functions if Width of Browser is less than this value
            fullWidth:"on",
            shadow:0                                //0 = no Shadow, 1,2,3 = 3 Different Art of Shadows -  (No Shadow in Fullwidth Version !)
        });
 });       

   jQuery(document).ready(function(){
      jQuery('#tabs div').hide();
      jQuery('#tabs div:first').show();
      jQuery('#tabs ul li:first').addClass('active');
      jQuery('#tabs ul li a').click(function(){ 
      jQuery('#tabs ul li').removeClass('active');
      jQuery(this).parent().addClass('active'); 
      var currentTab = jQuery(this).attr('href'); 
     jQuery('#tabs div').hide();
     jQuery(currentTab).show();
     return false;
    });
    });
于 2013-07-25T16:42:02.600 に答える
0

既定の html/css/js ランディング ページ テンプレートを Meteor で動作させる際に、この問題に遭遇しました。私の場合、ソリューションから jquery-1.11.1.min.js および jquery-1.11.1.min.map ファイルを削除すると、最新バージョンがパッケージとしてインストールされているため、問題は解決しました。これが将来のソリューション検索者に役立つことを願っています。

于 2015-02-08T05:20:18.953 に答える