1

私はスペイン語です (私の英語で申し訳ありません)。何か質問するためにここに書き込むのは初めてです。

Fancybox スクリプトが機能しない理由を何時間もデバッグして検索した後、Web サイトで 2 つのスクリプト間の競合を検索しました (現在はメンテナンス モードになっています)。

私は自分の Web サイトでいくつかのスクリプトを使用していますが、これら 2 つのスクリプトの間に競合があると断言できます。

http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/jquery.mousewheel-3.0.4.pack.js    
http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/jquery.fancybox-1.3.4.pack.js

http://www.planetdescargas.com/wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js?ver=3.0.5

最初の 2 つのスクリプトは jquery のプラグイン「fancybox」で、もう 1 つは wordpress プラグインのメインの JavaScript (Ajax) である BuddyPress です。

後者はfancyboxで競合を引き起こします。BuddyPress のスクリプトを削除すると、fancybox は完全に機能しますが、削除しないと機能しません。

BuddyPress のスクリプト global.js には、スクリプトを作成する最初の変数が定義されています。私はそれを次のように定義しようとしています:

var jq = jQuery.noConflict ();

しかし、まだ機能していません。

助言がありますか?

Firebugコンソールで私はこれを得ました:

c.easing[this.options.specialEasing && this.options.specialEasing[this.prop] || a] is not a function

[Detener en este error] e,this.options.orig[e]);this.options.c...++)ab||a.splice(b--,1);a.length||

の143行目

http://www.planetdescargas.com/wp-includes/js/jquery/jquery.js?ver=1.4.2

ありがとう

4

3 に答える 3

3

このように使用するだけです。

開くwp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js

上に追加:

jQuery.noConflict (jquery_working =! html bind);

番号 1264
に移動し ます。これを以下に追加します。

;(function(jQuery){  ///Add this before start jQuery.easing.
  jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing, {def:"easeOutQuad",swing:function(e,f,a,h,g){return ......
  // ...
})(jQuery); //Add this end of the call.

同様に、jQuery Cookie プラグインの競合エラーを解決できます。

于 2012-04-07T08:17:54.630 に答える
1

それはあなたが使用する方法ではありませんjQuery.noConflict()。シンボルnoConflict()の制御を解放します。$ただし、他のスクリプトから見ると、安全な方法 ( (function($){ }(jQuery))) を使用しているため、使用しnoConflicts()ても実際の効果はありません。

これを変える

var jq = jQuery.noConflict ();

これに:

jQuery.noConflict ();
var jq = jQuery;

確かめる。

ドキュメント: http://api.jquery.com/jQuery.noConflict/

于 2011-04-25T22:01:04.193 に答える
0

何が問題だったのかわかりませんが、問題は解決しました。テーマルートの functions.php でこのコードを使用します。

    function fancybox_js() {
            wp_enqueue_script('jquery.fancybox', 'http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/fancybox/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.3.4');
            wp_enqueue_script('jquery.easing', 'http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/fancybox/jquery.easing-1.3.pack.js', array('jquery'), '1.3');
            wp_enqueue_script('jquery.mousewheel', 'http://www.planetdescargas.com/wp-content/themes/bigfoot/javascripts/fancybox/jquery.mousewheel-3.0.4.pack.js', array('jquery'), '3.0.4');
    }

add_action('wp_enqueue_scripts', 'fancybox_js', 999); 

Easy Fancyboxという wordpress プラグインからライブラリを取得しましたが、すべて正常に動作するようになりました。ありがとう!

于 2011-04-26T14:37:18.190 に答える