IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Conflit mootools / Jquery avec Joomla


Sujet :

jQuery

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juin 2009
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 28
    Par défaut Conflit mootools / Jquery avec Joomla
    Bonjour à tous,

    voici mon soucis, je bosse sur un projet avec joomla qui utilise mootools, pour contourner le problème de compatibilité entre mootools et jquery, j'ai installé le petit script no conflict de jquery. (Je veux faire un slideshow avec jquery sur ma home page de template joomla).

    Je ne mis connais pas trop, et je suis confronté à un petit soucis, ce que j'ai tenté n'a pas fonctionné biggrin .

    Voila ma page index.html avec l'appel de la fonction jquery.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    <script src="../../../ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
     
    <script src="slideView.1.2.js" type="text/javascript"></script>
     
    <script type="text/javascript">
     
         jQuery.noConflict();
     
     
     
    $j(function() {
     
    	$j("#slideshow").slideView({
     
    		loop: true
     
    	});
     
    });
     
     
     
    </script>


    J'y ai intégré la le no conflict jquery et j'ai modifié le $ par $j.

    Le problème ne vient pas de la enfin, je crois.
    Le problème vient du fichier slideView.1.2.js . J'ai essayé de modifier le $ par $j. Ne vous moqué pas je suis peut être a la ramasse sur ce coup là ! a vous de me le dire . J'avoue c un peu du bricolage. biggrin

    voici ce fameux fichier
    Qu'en pensez vous ?

    Si quelqu'un trouve mon erreur, je lui serais très reconnaissant ! si il m'explique alors là c le pompom ! ! merci par avance !!!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    (function($j) {
     
    $j.iSlideView = {
     
    	build: function(user_options) {
     
    		var defaults = {
     
    			thumb: true,
     
    			thumbPrefix: "thumb_",
     
    			frame: {
     
    				isExist: false
     
    			},
     
    			slideBy : 1,
     
    			speed: 350,
     
    			easeOut: "swing",
     
    			easeIn: "swing",
     
    			easeThumb: "swing",
     
    			loop: false,
     
    			interval: 5000
     
    		},
     
    			options = $j.extend(defaults, user_options),
     
    			getThumbName = function(n,prefix) {
     
    				var arr = n.split("http://pagetalks.com/");
     
    				var tl = n.length;
     
    				var w = arr[arr.length-1].length;
     
    				return n.substr(0,tl-w-1)+"/"+prefix+arr[arr.length-1];
     
    			};
     
     
     
    		return $j(this).each(function() {
     
    			var x =$j(this),
     
    				list  = x.find("ul"),
     
    				links = list.find("a"),
     
    				images = list.find("img"),
     
    				slidebar,
     
    				thumbList,
     
    				thumbCon,
     
    				desc,
     
    				arrow,
     
    				back = options.leftArrow ? $j(options.leftArrow) : $j("<span class='arrowL arrow'><</span>"),
     
    				next = options.rightArrow ? $j(options.rightArrow) : $j("<span class='arrowR arrow'>></span>"),
     
    				xH,
     
    				xW,
     
    				li,
     
    				liW,
     
    				totalW,
     
    				xTotalH,
     
    				Pointer,
     
    				total,
     
    				tLink,
     
    				isBusy = false,
     
    				focusTo = function(p) {
     
    					var offsetT = - (xH * p);
     
    					if(isBusy) {
     
    						list.stop();
     
    					}
     
    					isBusy = true;
     
    					if(options.desc) {
     
    						desc.html(options.desc[p]);
     
    					} else {
     
    						desc.html(images.eq(p).attr("alt"));
     
    					}
     
    					list.animate({
     
    						top: offsetT +"px"
     
    					},options.speed,options.easeOut,function() {
     
    						isBusy = false;
     
    					});
     
    				};
     
     
     
    			links.click(function() {
     
    				return false;
     
    			});
     
     
     
    			//Insert a frame
     
    			var xW = x.width();
     
    			var xH = x.height();
     
    			if(options.frame.isExist) {
     
    				$j("<div class='slideFrame' />").appendTo(x).css({
     
    					width: x.width()-options.frame.width * 2,
     
    					height: x.height()-options.frame.width * 2,
     
    					border: options.frame.width+"px solid "+ options.frame.color,
     
    					position: "absolute",
     
    					top: 0,
     
    					left: 0,
     
    					zIndex: 4
     
    				});
     
    			}
     
     
     
    			//Insert thumb list, arrows, captions
     
    			desc = $j("<p class='desc' />").appendTo(x);
     
    			if(options.thumb || (!options.leftArrow || !options.rightArrow) ) {
     
    				slidebar = $j("<div class='slidebar' />").appendTo(x).fadeTo("fast",0.8);
     
    			}
     
    			if(options.thumb) {
     
    				thumbList = $j("<ul class='thumbList' />");
     
    				thumbCon = $j("<div class='wrap' />").append(thumbList).appendTo(slidebar);
     
    				//prepare sidebar thumbs
     
    				$j.each(images,function(index,img){
     
    					thumbList.append("<li><a href='#' id='"+ (index+1) +"'><img src='"+getThumbName(img.src,options.thumbPrefix)+"' alt='"+img.alt+"' /></a></li>");
     
    				});
     
     
     
    				li = thumbList.find("li");
     
    				liW = li.width();
     
    				totalW = li.length * liW;
     
    				thumbList.css("width",totalW).hover(function() {
     
    					slidebar.fadeTo("fast",1);
     
    				}, function() {
     
    					slidebar.fadeTo("fast",0.8);
     
    				});
     
    				tLink = thumbList.find("a").each(function(i) {
     
    					$j(this).hover(function() {
     
    						var id = this.id-1;
     
    						(function(index){
     
    							if(index!=Pointer) {
     
    								focusTo(id);	
     
    							}
     
    						})(i);
     
    					},function() {
     
    						focusTo(Pointer);
     
    					});
     
    				});
     
    			}
     
    			if(!options.leftArrow || !options.rightArrow) {
     
    				slidebar.append(next).prepend(back);
     
    			}
     
     
     
    			focusTo(0);
     
     
     
    			desc.fadeTo("fast",0.6).hover(function() {
     
    				$j(this).fadeTo("fast",0.9);
     
    			},function() {
     
    				$j(this).fadeTo("fast",0.6);
     
    			});
     
     
     
    			xTotalH = images.length * xH;
     
    			list.css("height",xTotalH);
     
     
     
    			Pointer = 0;
     
    			total = images.length;
     
     
     
    			if(!options.leftArrow) {back.fadeTo("fast",0.5);}
     
     
     
    			if(options.loop) {//loop the slide
     
    				setInterval(function() {
     
    					next.click();
     
    				},options.interval);
     
    			}
     
     
     
    			next.click(function() {
     
    			if( total - Pointer > options.slideBy ) {
     
    				if(options.thumb) {
     
    				var offsetL =  parseInt(thumbList.css("left")) - liW * options.slideBy;
     
    					thumbList.animate({
     
    						left: offsetL + "px"
     
    					},options.speed,options.easeThumb);
     
    				}
     
     
     
    				Pointer+=options.slideBy;
     
    				focusTo(Pointer);
     
     
     
    				if(!options.leftArrow) {
     
    					back.fadeTo("fast",1);
     
    				}
     
    			} else {
     
    				if(options.loop) {
     
    					if(options.thumb) {
     
    						thumbList.animate({
     
    							left: "0px"
     
    						},options.speed,options.easeThumb);
     
    					}
     
    					Pointer = 0;
     
    					focusTo(0);
     
    				} else {
     
    					next.fadeTo("fast",0.5);
     
    				}
     
    			}
     
    			return false;
     
    			});
     
     
     
    			back.click(function() {
     
    			if(Pointer!=0) {
     
    				if(options.thumb) {
     
    					var offsetL =  parseInt(thumbList.css("left")) + liW * options.slideBy;
     
    					thumbList.animate({
     
    						left: offsetL + "px"
     
    					},options.speed,options.easeThumb);
     
    				}
     
     
     
    				Pointer-=options.slideBy;
     
    				focusTo(Pointer);
     
     
     
    				if(!options.rightArrow) {
     
    					next.fadeTo("fast",1);
     
    					if(Pointer==0)//when slide back to the start
     
    						back.fadeTo("fast",0.5);
     
    				}
     
    			} 
     
    			return false;
     
    			});
     
    		});
     
    	}
     
    };
     
    $j.fn.slideView = $j.iSlideView.build;
     
    })(jQuery);

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Juin 2009
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 28
    Par défaut mootools jquery
    Quelqu'un aurait il une idée ? merci

  3. #3
    Membre confirmé
    Inscrit en
    Avril 2010
    Messages
    36
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 36
    Par défaut
    Pourquoi compliquer ton code en utilisant 2 bibliotheques diférente au lieu d'utiliser un slideshow basé sur mootools???

  4. #4
    Rédacteur

    Avatar de danielhagnoul
    Homme Profil pro
    Étudiant perpétuel
    Inscrit en
    Février 2009
    Messages
    6 389
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant perpétuel
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2009
    Messages : 6 389
    Billets dans le blog
    125
    Par défaut
    Bonjour.

    Première méthode avec noConflict :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <script>
    	var $j = jQuery.noConflict();
     
    	$j(function(){
    		$j("p").click(function(){
    			alert("OK !");
    		});
    	});
    </script>
    Deuxième méthode sans noConflict :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <script>
    	(function($){
    		$(function(){
    			$("p").click(function(){
    				alert("OK !");
    			});
    		});
    	})(jQuery);
    </script>

    Blog

    Sans l'analyse et la conception, la programmation est l'art d'ajouter des bogues à un fichier texte vide.
    (Louis Srygley : Without requirements or design, programming is the art of adding bugs to an empty text file.)

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2009
    Messages : 23
    Par défaut
    Hello,

    j'ai rencontré le même problème il y a a peine deux semaines de cela, jquery entrait en conflit avec le mootools de virtuemart...

    Après quelques recherches, j'ai trouvé une solution simple que j'ai posté ici:

    https://forum.joomla.fr/showthread.php?p=580572

    En espérant t'avoir aidé!

Discussions similaires

  1. Conflit entre JQuery et Mootools
    Par Petit Rasta dans le forum jQuery
    Réponses: 1
    Dernier message: 04/07/2011, 16h08
  2. comment faire cohabiter jquery avec FormCheck de Mootools ?
    Par clavier12AZQSWX dans le forum jQuery
    Réponses: 5
    Dernier message: 11/05/2010, 14h26
  3. Noconflict jQuery avec MooTools
    Par visual3d dans le forum jQuery
    Réponses: 3
    Dernier message: 29/07/2009, 23h48
  4. Conflit entre jQuery & mootools
    Par hare_ dans le forum jQuery
    Réponses: 1
    Dernier message: 10/05/2009, 19h32
  5. conflit de nom avec perlembed et winsock2
    Par clochette dans le forum MFC
    Réponses: 10
    Dernier message: 21/06/2005, 14h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo