JavaScript - Combinar dos funciones con librerias diferentes

 
Vista:
Imágen de perfil de Jordi
Val: 9
Ha aumentado su posición en 3 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

Combinar dos funciones con librerias diferentes

Publicado por Jordi (28 intervenciones) el 28/08/2014 12:07:58
Hola, quiero combinar dos funciones, una javascript y otra jquery. El caso es que por separado me funcionan a la perfección, pero no se como juntarlas para que vayan a la vez.

Funcion javascript que me carga una pagina php dentro de un div:
1
2
3
4
5
6
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script language="javascript" type="text/javascript">
   function cargarPagina(div, pagina){
       $(div).load(pagina);
    }
</script>


Funcion jquery que muestra un div, y oculta los otros:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script type='text/javascript' src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
   $(document).ready(function(){
      $("#boton1").click(function () {
         $('contingut1').show("slow");
         $('contingut2').hide("slow");
         $('contingut3').hide("slow");
      });
      $("#boton2").click(function () {
         $('contingut1').hide("slow");
         $('contingut2').show("slow");
         $('contingut3').hide("slow");
      });
      $("#boton3").click(function () {
         $('contingut1').hide("slow");
         $('contingut2').hide("slow");
         $('contingut3').show("slow");
      });
});
</script>


Todo esto se tendria que ejecutar al hacer click a estos links:
1
2
3
4
5
<a href="javascript:void()" onclick="cargarPagina('#contingut1','contingut/clientAlta.php')"><img id="boton1" src="assets/icons/clientNou.png" alt="Nou Client" title="Nou Client"/></a>
 
<a href="javascript:void()" onclick="cargarPagina('#contingut2','contingut/clients.php')"><img id="boton2" src="assets/icons/clients.png" alt="Clients" title="Clients"/></a>
 
<a href="javascript:void()" onclick="cargarPagina('#contingut3','contingut/ventaAlta.php')"><img id="boton3" src="assets/icons/ventaNova.png" alt="Nova Venta" title="Nova Venta"/></a>


He leído que para que se ejecuten a la vez lo puedo hacer con "easing" pero no tengo ni idea de javascript y no se usarlo...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Combinar dos funciones con librerias diferentes

Publicado por xve (2100 intervenciones) el 28/08/2014 17:26:50
Hola Jordi, he probado tu código creando un ejemplo, y el:
javascript:void() me da error en google chome...

he probado tu código así, y me ha funcionado los dos eventos sin problema:

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
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="utf-8">
    <script src="http://code.jquery.com/jquery-1.11.1.js" type="text/javascript"></script>
 
	<script>
	function cargarPagina(div, pagina){
		$(div).load(pagina);
	};
	$(document).ready(function(){
		$("#boton1").click(function(){
			$('contingut1').show("slow");
			$('contingut2').hide("slow");
			$('contingut3').hide("slow");
		});
		$("#boton2").click(function(){
			$('contingut1').hide("slow");
			$('contingut2').show("slow");
			$('contingut3').hide("slow");
		});
		$("#boton3").click(function(){
			$('contingut1').hide("slow");
			$('contingut2').hide("slow");
			$('contingut3').show("slow");
		});
	});
	</script>
 
</head>
 
<body>
<a href="#" onclick="cargarPagina('#contingut1','contingut/clientAlta.php')"><img id="boton1" src="assets/icons/clientNou.png" alt="Nou Client" title="Nou Client"/></a>
 
<a href="#" onclick="cargarPagina('#contingut2','contingut/clients.php')"><img id="boton2" src="assets/icons/clients.png" alt="Clients" title="Clients"/></a>
 
<a href="#" onclick="cargarPagina('#contingut3','contingut/ventaAlta.php')"><img id="boton3" src="assets/icons/ventaNova.png" alt="Nova Venta" title="Nova Venta"/></a>
 
<div id="contingut1"></div>
<div id="contingut2"></div>
<div id="contingut3"></div>
</body>
</html>

Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Jordi
Val: 9
Ha aumentado su posición en 3 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

Combinar dos funciones con librerias diferentes

Publicado por Jordi (28 intervenciones) el 29/08/2014 13:47:39
Gracias xve. Tu respuesta funciona a la perfección!!

También he estado probando y así también funciona:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!-- Libreria jQuery -->
<script type='text/javascript' src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
 
<script type="text/javascript">
	$(document).ready(function(){
		$("#boton1").click(function () {
			$('contingut1').show("slow");
			$('contingut2').hide("slow");
			$('contingut1').load('contingut/clientAlta.php');
		});
		$("#boton2").click(function () {
			$('contingut1').hide("slow");
			$('contingut2').show("slow");
			$('contingut2').load('contingut/clients.php');
		});
	});
</script>

No se si sera tan optimo pero así me lo organizo por botones, y cada uno que haga su función.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Combinar dos funciones con librerias diferentes

Publicado por xve (2100 intervenciones) el 29/08/2014 14:00:15
Así esta mucho mejor y mas claro!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar