Foro de elhacker.net

Programación => Desarrollo Web => Mensaje iniciado por: soru13 en 22 Mayo 2012, 23:46 pm



Título: Implementar 2 jquery diferentes.
Publicado por: soru13 en 22 Mayo 2012, 23:46 pm
Hola, resulta que en la misma página necesito implementar un archivo "jquery-1.7.1.js" y a la vez otro "jquery.min.js".

El problema es que si incluyo este último, me dejan de funcionar los scripts que usan "jquery-1.7.1.js", y necesito los dos ya que cada uno sirve para distintos scripts.

¿Alguién sabe como puedo arreglarlo?

Un saludo y gracias.


Título: Re: Implementar 2 jquery diferentes.
Publicado por: Kase en 23 Mayo 2012, 06:51 am
pekeña y rapida busqueda en google... http://www.sqleros.com.ar/2011/05/que-es-lo-que-hace-jquerynoconflict.html


Título: Re: Implementar 2 jquery diferentes.
Publicado por: soru13 en 23 Mayo 2012, 15:52 pm
Estuve mirando varios tutoriales y esto es lo más cercano que llegué a hacer, pero aun así no funciona.

slider.js
Código
  1. $(function() {
  2. $( "#slider-range" ).slider({
  3. range: true,
  4. min: 18,
  5. max: 65,
  6. values: [ 18, 25 ],
  7. slide: function( event, ui ) {
  8. $( "#amount" ).val( "" + ui.values[ 0 ] + " - " + ui.values[ 1 ] );
  9. }
  10. });
  11. $( "#amount" ).val($( "#slider-range" ).slider( "values", 0 ) +
  12. " - " + $( "#slider-range" ).slider( "values", 1 ) );
  13. })(jQuery);
  14. jQuery.noConflict();
  15. $(function() {
  16. $( "#tarifa" ).slider({
  17. range: true,
  18. min: 20,
  19. max: 600,
  20. values: [ 20, 80 ],
  21. slide: function( event, ui ) {
  22. $( "#cantidad" ).val(ui.values[ 0 ] + " - " + ui.values[ 1 ] + " € " );
  23. }
  24. });
  25. $( "#cantidad" ).val($( "#tarifa" ).slider( "values", 0 ) +
  26. " - " + $( "#tarifa").slider("values", 1 ) + " € ");
  27. })(jQuery);
  28. jQuery.noConflict();

index.html

Código
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml"><head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5.  
  6.  
  7. <link rel="stylesheet" href="inc/jquery.ui.all.css">
  8. <script src="./inc/jquery-1.7.1.js"></script>
  9.    <script>jQuery.noConflict();</script>
  10. <script src="./inc/jquery.ui.core.js"></script>
  11. <script src="./inc/jquery.ui.widget.js"></script>
  12. <script src="./inc/jquery.ui.mouse.js"></script>
  13. <script src="./inc/jquery.ui.slider.js"></script>
  14.    <script src="./inc/slider_form.js"></script>
  15. <!-- lightbox -->
  16. <script type="text/javascript" src="./inc/lightbox/javascript/jquery.min.js"></script>
  17. <script>jQuery.noConflict();</script>
  18. <link rel="stylesheet" type="text/css" href="./inc/lightbox/javascript/lightbox/themes/default/jquery.lightbox.css" />
  19. <script type="text/javascript" src="./inc/lightbox/javascript/lightbox/jquery.lightbox.min.js"></script>
  20. <!-- fin -->
  21. </head>
  22.  
  23. <body><a href="contacto.php?lightbox[iframe]=true&lightbox[width]=700&lightbox[height]=700" class="lightbox">ABRIR</a>
  24.  
  25. <div class="demo"><!-- SLIDER EDAD -->
  26. <p>
  27. <label for="amount">Edad:</label>
  28.    <input type="text" name="edad" id="amount" style="border:0; color:#f6931f; font-weight:bold; " />
  29. </p>
  30.  
  31. <div id="slider-range" style="width:150px;margin-left:10px;"></div>
  32.  
  33.  
  34. <script type="text/javascript">
  35.  jQuery(document).ready(function($){
  36.    $('.lightbox').lightbox();
  37.  });
  38. </script>
  39. </body>
  40. </html>

¿Algún consejo?

Gracias


Título: Re: Implementar 2 jquery diferentes.
Publicado por: [u]nsigned en 23 Mayo 2012, 18:31 pm
El archivo jquery.min.js de que version es?

No veo la necesidad de usar versiones diferentes, solo deberias usar la mas nueva, y evitar usar plugins o widgets que usen versiones viejas.


Título: Re: Implementar 2 jquery diferentes.
Publicado por: soru13 en 23 Mayo 2012, 21:23 pm
el caso es que si quito el "jquery.min.js" y dejo el "jquery-1.7.1.js", me deja de funcionar el lightbox que es el que funciona cuando estan los 2 scripts en la misma página.


Título: Re: Implementar 2 jquery diferentes.
Publicado por: EFEX en 24 Mayo 2012, 06:34 am
multiple-versions-of-jquery-on-the-same-page (http://forum.jquery.com/topic/multiple-versions-of-jquery-on-the-same-page)

how-to-two-different-jquery-on-the-same-page (http://stackoverflow.com/questions/4927355/how-to-two-different-jquery-on-the-same-page-the-page-to-be-included-has-the/4927443#4927443)

Código
  1.    <head>
  2.        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  3.        <script type="text/javascript">
  4.            jQuery.noConflict(  )
  5.            jQuery144 = jQuery
  6.            console.log(jQuery144, jQuery)
  7.        </script>
  8.        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
  9.        <script type="text/javascript">
  10.            jQuery144(function($) {
  11.                console.log("hello", $.fn.jquery)
  12.            })
  13.            jQuery(function($) {
  14.                console.log("world", $.fn.jquery)
  15.            })
  16.        </script>
  17.    </head>
  18.    <body>
  19.    </body>
  20. </html>
  21.  

Es un dolor de cabeza hacer esta practica.


Título: Re: Implementar 2 jquery diferentes.
Publicado por: soru13 en 24 Mayo 2012, 22:05 pm
SOLUCIONADO, GRACIAS!