2017-01-14 8 views
1

私は現在働いているWooCommerce搭載のストアでsmoothState.jsを実装しました。ライブデモは、このリンクで見つけることができます:私はまだ持ってるhttp://demos.oosh.co/btWooCommerceのAdd-to-Cartボタンとログイン/登録リンクからsmoothState.jsを無効にする方法

唯一の問題は2つです:あなたがクリックすると

  1. カートに追加]ボタンのデフォルトのWooCommerce AJAX呼び出しが干渉しているようですページがsmoothState.jsアクションになるようにします。 Cart to AddボタンでsmoothState.jsを非アクティブにする方法が欲しいです。

  2. ログアウトをクリックしてログアウトすると、たとえば、ログインや登録を試みるとsmoothState.jsが実行され、他のリンクは適切なアクションにリダイレクトされません。だから、これらのログインと登録リンクでも、smoothState.jsを無効にしたいと思います。

このアシスタントは他にも有益でしょうか?

ところで、私はsmoothState.jsを呼び出すために使用しているコードです。私はhttps://webdesign.tutsplus.com/tutorials/how-to-integrate-smoothstatejs-into-a-wordpress-theme--cms-26610

// Using smoothstate-js to Ajax-load pages 
(function($) { 
    function addBlacklistClass() { 
    $('a').each(function() { 
     if (this.href.indexOf('/wp-admin/') !== -1 || 
     this.href.indexOf('/wp-login.php') !== -1) { 
     $(this).addClass('wp-link'); 
     } 
    }); 
    } 

    $(function() { 
    addBlacklistClass(); 

    var settings = { 
     anchors: 'a', 
     blacklist: '.wp-link', 
     onStart: { 
     duration: 320, 
     render: function ($container) { 
      $container.addClass('slide-out'); 
     } 
     }, 
     onAfter: function($container) { 
     addBlacklistClass(); 

     var $hash = $(window.location.hash); 
     if ($hash.length !== 0) { 
      var offsetTop = $hash.offset().top; 

      $('body, html').animate({ 
       scrollTop: (offsetTop - 60), 
      }, { 
       duration: 320 
      }); 
     } 

     $container.removeClass('slide-out'); 
     } 
    }; 

    $('#app').smoothState(settings); 
    }); 
})(jQuery); // End smoothstate-js 

おかげで助けて、その後たくさんこのリンクでEnvatoによってTutsplusのチュートリアルから、このコードをつかむました。

+0

さらにこれを取得しましたか?私は同じ問題を抱えていますが、あなたの解決策は助けになりませんでした。すべての情報は本当に感謝しています。 – anti000gravity

答えて

0

ブラックリスト機能に数行のコードを追加しました。これは問題を解決するようです。私はすべてのことが正しいことを確かめるために調査を続けます。今のところ、あなたが私のコードを手に入れたいのを除いて、私は大丈夫だと思います。

(function($) { 
    function addBlacklistClass() { 
    $('a').each(function() { 
     if (this.href.indexOf('/wp-admin/') !== -1 || 
     this.href.indexOf('/wp-login.php') !== -1 || 
     this.href.indexOf('/?add-to-cart') !== -1 || 
     this.href.indexOf('?remove_item') !== -1) { 
     $(this).addClass('no-smoothState'); 
     } 
    }); 

    $('input[type="submit"]').each(function() { 
     $(this).addClass('no-smoothState'); 
    }); 
    } 

    $(function() { 
    addBlacklistClass(); 

    var settings = { 
     anchors: 'a', 
     forms: 'input', 
     blacklist: '.no-smoothState', 
     onStart: { 
     duration: 320, 
     render: function ($container) { 
      $container.addClass('slide-out'); 
     } 
     }, 
     onAfter: function($container) { 
     addBlacklistClass(); 

     var $hash = $(window.location.hash); 
     if ($hash.length !== 0) { 
      var offsetTop = $hash.offset().top; 

      $('body, html').animate({ 
       scrollTop: (offsetTop - 60), 
      }, { 
       duration: 320 
      }); 
     } 

     $container.removeClass('slide-out'); 
     } 
    }; 

    $('#app').smoothState(settings); 
    }); 
})(jQuery); 
関連する問題