0

私はフル ページ サイトで作業しており、Fullpage.js プラグインを使用することにしましたが、AJAX 要求を介してコンテンツを読み込むという点でいくつかの問題があります。ページに JSON コンテンツを入力していますが、何らかの理由で scrollOverflow オプションが正しく機能していません。さらに興味深いのは、XAMPP 環境では問題なく動作しますが、ライブ ホスト環境 (Bluehost) では失敗することです。サイト リソースが適切に読み込まれていないような気がしますが、それが問題を引き起こす可能性があるかどうかはわかりません。コンソール エラーはなく、すべてのリソースが読み込まれています。

初期化:

$(document).ready(function() {
$.ajax({
    type: 'POST',
    url: 'content.json',
    dataType: 'json',
    contentType: "text/json; charset=utf-8",
    success: function(e) {
        $('.slide').each(function(index){
            console.log(index);
            $(this).children('.fp-tableCell').html('<span class = "center"><div class="circle-logo"><div class="circle-fill"><i class="'+e.platform[index].i+'"></i></div></div><h1 class = "montserrat">'+e.platform[index].h+'</h1><p class = "hind">'+e.platform[index].p+'</p><span>');
        });
        for(var i = 0; i<e.about.length; i++){
            $('#section2').children('.fp-tableCell').append('<h2 class = "montserrat">'+e.about[i].h+'</h2><p class = "hind">'+e.about[i].p+'</p>');
        }
        $('#section2').children('.fp-tableCell').append('<hr>');
        $('#section2').children('.fp-tableCell').append('<p class = "hind">CRAFTED BY DAVE | &copy; NATHAN</p>');
    },
    error: function(e){
        console.log(e);
    }
});

$('#downhint').click(function(){
    console.log('click');
    $.fn.fullpage.moveSectionDown();
});

$('#fullpage').fullpage({
    sectionsColor: ['transparent', '#021b80', '#FFF'],
    anchors: ['landing', 'platform', 'about'],
    menu: '#menu',
    scrollOverflow: true,
    slidesNavigation: true,
    afterLoad: function(anchorLink, index){

        $('.fp-table .active').css('overflow-y','auto');

        if(index == 1){
            $('#menu li:nth-child(1) a').addClass('active-link');
            $('#menu li:not(:nth-child(1)) a').removeClass('active-link');
        }
        if(index == 2){
            $('#menu li:nth-child(2) a').addClass('active-link');
            $('#menu li:not(:nth-child(2)) a').removeClass('active-link');
        }
        if(index == 3){
            $('#menu li:nth-child(3) a').addClass('active-link');
            $('#menu li:not(:nth-child(3)) a').removeClass('active-link');
        }

    }
});
$(window).scroll  
});

内容:

    <link rel="stylesheet" type="text/css" href="css/index.css" />

    <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Hind' rel='stylesheet' type='text/css'>
    <link href='css/bootstrap.min.css' rel='stylesheet' type='text/css'>
    <link href='fonts/genericons/genericons/genericons.css' rel='stylesheet' type='text/css'>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src="js/jquery.slimscroll.min.js"></script>
    <script type="text/javascript" src="fullpage/jquery.fullPage.js"></script>

私が言えることは、必要なファイルとスクリプトをすべてロードしたことです。前もって感謝します。

4

1 に答える 1

1

あなたの最後のコメントに基づいています。$.fn.fullpage.reBuild()新しいコンテンツを DOM 構造にロードした直後に呼び出す必要があります。

このようにして、fullpage.js はコンテンツ サイズを再計算し、必要に応じてスクロール バーを作成します。

ドキュメントから:

reBuild() 新しいウィンドウ サイズまたはその内容に合わせて DOM 構造を更新します。AJAX 呼び出しまたはサイトの DOM 構造の外部変更と組み合わせて使用​​するのに理想的です。

于 2015-04-28T09:37:51.830 に答える