<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>giancarlospot - desarrollo web &#187; Javascript</title>
	<atom:link href="http://www.giancarlospot.com/categoria/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.giancarlospot.com</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 18:16:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Acordion con JQuery y con el plugin Jquery easing</title>
		<link>http://www.giancarlospot.com/javascript/acordion-con-jquery-y-con-el-plugin-jquery-easing.html</link>
		<comments>http://www.giancarlospot.com/javascript/acordion-con-jquery-y-con-el-plugin-jquery-easing.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:24:57 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[acordion]]></category>
		<category><![CDATA[easing]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.giancarlospot.com/?p=284</guid>
		<description><![CDATA[El uso del acordion en las páginas webs de ahora son muy usados y es más simple de lo que uno se puede imaginar, sobre todo si lo usas con JQuery. En realidad qué es? Puede ser un &#60;div&#62; oculto que los muestras cuando le das clic a otro DIV, bueno yo uso DIVS pero [...]]]></description>
			<content:encoded><![CDATA[<p>El uso del acordion en las páginas webs de ahora son muy usados y es más simple de lo que uno se puede imaginar, sobre todo si lo usas con <a href="http://jquery.com/" target="_blank">JQuery</a>. En realidad qué es? Puede ser un &lt;div&gt; oculto que los muestras cuando le das clic a otro DIV, bueno yo uso DIVS pero puedes usar un <a href="http://www.w3.org/MarkUp/HTMLPlus/htmlplus_11.html" target="_blank">&lt;p&gt;</a> u otra etiqueta.<br />
<span id="more-284"></span>Primero creamos los div con la información. Vamos a ponerle un número para poder identificar más rápido los títulos y la información en base a al div en el que se encuentran.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;acordion&quot;&gt;
&nbsp;
&lt;div id=&quot;item_1&quot; class=&quot;item&quot;&gt;
&nbsp;
&lt;div id=&quot;titulo_1&quot; class=&quot;titulo&quot;&gt;Título 1&lt;/div&gt;
&nbsp;
&nbsp;
&lt;div id=&quot;info_1&quot; class=&quot;info&quot;&gt;Información 1&lt;/div&gt;
&lt;/div&gt;
&nbsp;
&nbsp;
&lt;div id=&quot;item_2&quot; class=&quot;item&quot;&gt;
&nbsp;
&lt;div id=&quot;titulo_2&quot; class=&quot;titulo&quot;&gt;Título 2&lt;/div&gt;
&nbsp;
&nbsp;
&lt;div id=&quot;info_2&quot; class=&quot;info&quot;&gt;Información 2&lt;/div&gt;
&lt;/div&gt;
&nbsp;
&nbsp;
&lt;div id=&quot;item_3&quot; class=&quot;item&quot;&gt;
&nbsp;
&lt;div id=&quot;titulo_3&quot; class=&quot;titulo&quot;&gt;Título 3&lt;/div&gt;
&nbsp;
&nbsp;
&lt;div id=&quot;info_3&quot; class=&quot;info&quot;&gt;Información 3&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>Hemos encerrado todo en un div con el estilo &#8220;acordion&#8221;, dentro hay grupos, agrupados por un div con el estilo &#8220;item&#8221; y dentro hay dos divs, el título (estilo &#8220;titulo&#8221;) y la información (estilo &#8220;info&#8221;). Vamos a darle estilo a estas capas.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div.acordion<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;Palatino Linotype&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Book Antiqua&quot;</span><span style="color: #00AA00;">,</span> Palatino<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.item</span> div.titulo<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FF6</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">21px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.item</span> div.info<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#69F</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Le hemos dado tamaño, tipografía, colores, bordes, etc. Esto lo puedes cambiar en base a los colores que quieras utilizar o la tipografía, sin que esto percuta con el funcionamiento. Ahora lo que se debe hacer es ocultar la información, para que solo sea mostrada cuando se le de clic al título, esto lo hacemos en el estilo &#8220;info&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.item</span> div.info<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#69F</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Ahora veamos el Javascript, yo llamo a los JS antes de cerrar la etiqueta BODY. Vamos a llamar al los JS jquery.js y jquery.easing.js. Además, cuando termine de cargar el documento vamos a hacer que el acordion funcione, para esto vamos a utilizar el método <a href="http://docs.jquery.com/Core/each">each</a> de Jquery. Esto lo utilizo para que se sepa cual es el título y la información de cada &#8220;item&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;!--mce:0--&gt;&lt;/script&gt;
&lt;script src=&quot;jquery.easing.js&quot; type=&quot;text/javascript&quot;&gt;&lt;!--mce:1--&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;!--</span>mce<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #339933;">--&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Luego recuperamos el titulo y la información por cada &#8220;item&#8221;, aquí es donde usamos el número que le pusimos a los divs. Cuando le demos clic al título, su info respectiva se mostrará o se ocultará dependiendo del caso.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.acordion div.item&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//RECUPERAMOS EL NÚMERO</span>
		<span style="color: #003366; font-weight: bold;">var</span> titulo <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;div#titulo_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> info <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;div#info_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span>titulo<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Como ven, hasta ahí ya funciona el acordio, ahora pongámosle el easing y tiempo, el tiempo es en milisegundos, osea cada 1000 es 1 segundo.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> tiempoAbrir <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.acordion div.item&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> titulo <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;div#titulo_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> info <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;div#info_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span>titulo<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span> tiempoAbrir<span style="color: #339933;">,</span> easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;easeOutElastic&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Si prueban hasta este punto, van a ver que cuando se abre uno no se cierra el otro. Para que no estén dos abiertos lo que se debe hacer es que cuando se abra uno se guarda en una variable el que está abierto, entonces si se le da clic a otro se cierra primero éste y luego se abre el otro.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> abierto<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> tiempoAbrir <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> tiempoCerrar <span style="color: #339933;">=</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.acordion div.item&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> titulo <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;div#titulo_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> info <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;div#info_&quot;</span><span style="color: #339933;">+</span>num<span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span>titulo<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>abierto <span style="color: #339933;">==</span> info<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span> tiempoCerrar<span style="color: #339933;">,</span> easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;easeInElastic&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> abierto <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;undefined&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span> tiempoAbrir<span style="color: #339933;">,</span> easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;easeOutElastic&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					abierto <span style="color: #339933;">=</span> info<span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span>abierto<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span> tiempoCerrar<span style="color: #339933;">,</span> easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;easeInElastic&quot;</span><span style="color: #339933;">,</span> complete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						$<span style="color: #009900;">&#40;</span>info<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span> tiempoAbrir<span style="color: #339933;">,</span> easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;easeOutElastic&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						abierto <span style="color: #339933;">=</span> info<span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>El plugin jquery.easing.js tiene diferentes tipos de movimientos, los pueden ver en bajando el ejemplo</p>
<p><a href="http://www.giancarlospot.com/ejemplos/acordion-con-easing.html" target="_blank">Mira el ejemplo</a><br />
<a href="http://www.giancarlospot.com/descargas/acordion-con-easing.zip">Descarga el ejemplo</a></p>
<p>No olvides dejar tus comentarios</p>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/javascript/acordion-con-jquery-y-con-el-plugin-jquery-easing.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extensión de Extjs para Dreamweaver</title>
		<link>http://www.giancarlospot.com/javascript/extension-de-extjs-para-dreamweaver.html</link>
		<comments>http://www.giancarlospot.com/javascript/extension-de-extjs-para-dreamweaver.html#comments</comments>
		<pubDate>Thu, 12 Mar 2009 16:15:06 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[dreamweaver]]></category>
		<category><![CDATA[extjs]]></category>

		<guid isPermaLink="false">http://www.giancarlospot.com/?p=209</guid>
		<description><![CDATA[Así es. Podemos instalar una extensión de la famosa librería Extjs a nuestro Dreamweaver desde la versión MX 2004 en adelante. Así como cuando escribimos código HTML o CSS en el Dreamweaver y aparece una ventanita mostrándonos el &#8220;código&#8221; que puede ir con la palabra que estamos escribiendo, esta extensión funciona de la misma forma [...]]]></description>
			<content:encoded><![CDATA[<p>Así es. Podemos instalar una extensión de la famosa librería Extjs a nuestro Dreamweaver desde la versión MX 2004 en adelante. Así como cuando escribimos código HTML o CSS en el Dreamweaver y aparece una ventanita mostrándonos el &#8220;código&#8221; que puede ir con la palabra que estamos escribiendo, esta extensión funciona de la misma forma con el &#8220;código&#8221; del Extjs. <a href="http://www.spket.com/dreamweaver-extension.html" target="_blank">Pueden entrar a esta página para ver más detalles y descargar la extensión</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/javascript/extension-de-extjs-para-dreamweaver.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Llenar combo con Ajax y PHP</title>
		<link>http://www.giancarlospot.com/javascript/llenar-combo-con-ajax-y-php.html</link>
		<comments>http://www.giancarlospot.com/javascript/llenar-combo-con-ajax-y-php.html#comments</comments>
		<pubDate>Tue, 10 Mar 2009 14:04:16 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[combo]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.giancarlospot.com/?p=192</guid>
		<description><![CDATA[He visto muchas preguntas en foros de cómo poder modificar un combo según el valor que el visitante selecciona de otro. Esto es más sencillo de lo que muchos creen. Con este video vamos a ver cómo poder modificar un combo utilizando Ajax. En mi caso uso JQuery pero no es necesario, ya lo verán. [...]]]></description>
			<content:encoded><![CDATA[<p>He visto muchas preguntas en foros de cómo poder modificar un combo según el valor que el visitante selecciona de otro. Esto es más sencillo de lo que muchos creen. Con este video vamos a ver cómo poder modificar un combo utilizando Ajax. En mi caso uso JQuery pero no es necesario, ya lo verán.</p>
<p><span id="more-192"></span></p>
<div id="video_flash" style="text-align: center;"></div>
<p><a href="http://www.giancarlospot.com/descargas/combo_ajax.zip">Descargar Ejemplo</a></p>
<p><a href="http://www.giancarlospot.com/javascript/empezando-con-jqueryempezando-con-jquery.html">Conocer más de JQuery</a><br />
<a href="http://www.giancarlospot.com/php/json-php-y-javascriptjson-php-y-javascript.html">Conocer más de JSON</a><br />
<a href="http://getfirebug.com/">Descarga el Add-on Firebug que utilizo en el tutorial</a><br />
<a href="http://www.php.net/manual/es/function.sleep.php">Acerca de la función Sleep en PHP</a><br />
<script type="text/javascript" src="/js/swfobject.js"></script><br />
 <script type="text/javascript">
var so = new SWFObject('/swf/player.swf','player','449','386','8');
so.useExpressInstall('/swf/expressinstall.swf');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('flashvars','file=/videos/llenar_combo_con_ajax_y_php.flv&#038;image=/images/videos/llenar_combo_ajax_php.jpg');
so.addParam("wmode", "opaque");
so.write('video_flash');
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/javascript/llenar-combo-con-ajax-y-php.html/feed</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Pasar tus links a Ajax con Jquery</title>
		<link>http://www.giancarlospot.com/javascript/pasar-tus-links-a-ajax-con-jquery.html</link>
		<comments>http://www.giancarlospot.com/javascript/pasar-tus-links-a-ajax-con-jquery.html#comments</comments>
		<pubDate>Thu, 05 Mar 2009 01:44:32 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.giancarlospot.com/?p=169</guid>
		<description><![CDATA[Hoy día estaba con Javier de Mancormedia y ya había terminado una aplicación bien interesante, pero el siguiente paso era pasar todos los links para que funcionen con Ajax. No ibamos a cambiar todos los links para que funcionen con Ajax, uno por uno, entonces se me ocurrió una idea bien sencilla pero efectiva. Por [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy día estaba con Javier de <a href="http://www.mancormedia.com" target="_blank">Mancormedia</a> y ya había terminado una aplicación bien interesante, pero el siguiente paso era pasar todos los links para que funcionen con Ajax. No ibamos a cambiar todos los links para que funcionen con Ajax, uno por uno, entonces se me ocurrió una idea bien sencilla pero efectiva.</p>
<p><span id="more-169"></span>Por ejemplo, toda la aplicación estaba dentro de un div con el id &#8220;data&#8221;. Entonces con unas simples líneas de javascript se pudo realizar este cambio sin la necesidad de tocar nada de la aplicación.</p>
<p>Primero están los links dentro del DIV</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xhtml" style="font-family:monospace;">&lt;div id=&quot;data&quot;&gt;
	&lt;a href=&quot;link1.html&quot;&gt;Link 1&lt;/a&gt;&lt;br /&gt;
	&lt;a href=&quot;link2.html&quot;&gt;Link 2&lt;/a&gt;&lt;br /&gt;
	&lt;a href=&quot;link3.html&quot;&gt;Link 3&lt;/a&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Ahora solo llamamos a la librería JQuery y escribímos nuestro código paso a paso</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;div id=&quot;data&quot;&gt;
	&lt;a href=&quot;link1.html&quot;&gt;Link 1&lt;/a&gt;&lt;br /&gt;
	&lt;a href=&quot;link2.html&quot;&gt;Link 2&lt;/a&gt;&lt;br /&gt;
    &lt;a href=&quot;link3.html&quot;&gt;Link 3&lt;/a&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> Cargo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#data a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span>Cargo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Primero decimos que cuando cargue la página llame a la función &#8220;Cargo&#8221;, donde todas las etiquetas &#8220;&lt;a&gt;&#8221; dentro de &#8220;&lt;div id=&#8221;data&#8221;&gt;&lt;/div&gt;&#8221; luego de ser cliqueadas muestren una alerta de la ruta absoluta de su destino pero luego con el &#8220;return false;&#8221; estamos diciendo que no vaya a ningún sitio.</p>
<p>Lo que vamos a hacer ahora es cargar esta misma ruta en el DIV mediante Ajax</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;div id=&quot;data&quot;&gt;
	&lt;a href=&quot;link1.html&quot;&gt;Link 1&lt;/a&gt;&lt;br /&gt;
	&lt;a href=&quot;link2.html&quot;&gt;Link 2&lt;/a&gt;&lt;br /&gt;
    &lt;a href=&quot;link3.html&quot;&gt;Link 3&lt;/a&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> Cargo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#data a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		UpdateDiv<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> UpdateDiv<span style="color: #009900;">&#40;</span>Url<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'get'</span><span style="color: #339933;">,</span>
		url<span style="color: #339933;">:</span> Url<span style="color: #339933;">,</span>
		dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'html'</span><span style="color: #339933;">,</span>
		success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#data&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span>Cargo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Con este ejemplo hacemos que cargue la página en el &#8220;DIV&#8221;, pero qué pasa si queremos cargar la información en otro DIV y que sea dinámico según el link? Igual de sencillo. Solamente ponemos un atributo más en la etiqueta &#8220;&lt;a&gt;&#8221;, &#8220;rel&#8221;, y lo igualamos al nombre del DIV que queremos que cargue la página.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;div id=&quot;data&quot;&gt;
	&lt;a href=&quot;link1.html&quot; rel=&quot;data2&quot;&gt;Link 1&lt;/a&gt;&lt;br /&gt;
	&lt;a href=&quot;link2.html&quot;&gt;Link 2&lt;/a&gt;&lt;br /&gt;
    &lt;a href=&quot;link3.html&quot;&gt;Link 3&lt;/a&gt;
&lt;/div&gt;
&nbsp;
&lt;!-- Aquí estamos creando la otra capa --&gt;
&lt;div id=&quot;data2&quot;&gt;&lt;/div&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> Cargo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#data a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		UpdateDiv<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> UpdateDiv<span style="color: #009900;">&#40;</span>Url<span style="color: #339933;">,</span> Capa<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	Capa <span style="color: #339933;">=</span> Capa<span style="color: #339933;">||</span><span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">;</span>
	$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'get'</span><span style="color: #339933;">,</span>
		url<span style="color: #339933;">:</span> Url<span style="color: #339933;">,</span>
		dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'html'</span><span style="color: #339933;">,</span>
		success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>Capa<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span>Cargo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Si quieren que todos los links carguen por ajax, pero algunos no, podemos hacer que el valor de &#8220;rel&#8221; sea &#8220;no-ajax&#8221;. Solo cambiamos la función &#8220;Cargo&#8221; (por cierto, pueden darle cualquier nombre a las funciones)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> Cargo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rel</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;no-ajax&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			UpdateDiv<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>En este caso, todos los links cargaran por ajax y la información se podrán en el div con el ID igual al valor que tiene el atributo &#8220;rel&#8221; de los links, excepto los que tengan como valor &#8220;no-ajax&#8221;</p>
<p>Eso es todo, como ven solo son unas pocas líneas. Todo es cosa de creatividad y hacer las funciones de tal manera que funcione para todos los casos.</p>
<p>No olviden crear las páginas para que no tengan problemas con los 404.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/javascript/pasar-tus-links-a-ajax-con-jquery.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Empezando con JQuery</title>
		<link>http://www.giancarlospot.com/javascript/empezando-con-jquery.html</link>
		<comments>http://www.giancarlospot.com/javascript/empezando-con-jquery.html#comments</comments>
		<pubDate>Tue, 03 Mar 2009 02:34:20 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.giancarlospot.com/?p=143</guid>
		<description><![CDATA[JQuery es una librería con poco peso muy efectiva para trabajar con el DOM. Esta librería es muy fácil de utilizar y más aun si conocer bien la sintaxis de los CSS. Utilizalo es muy sencillo y más aun que existe una amplia variedad de Widgets para el JQuery. Puedes descargar la librería de JQuery [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jquery.com">JQuery</a> es una librería con poco peso muy efectiva para trabajar con el <a href="http://es.wikipedia.org/wiki/Document_Object_Model" target="_blank">DOM</a>. Esta librería es muy fácil de utilizar y más aun si conocer bien la sintaxis de los <a href="http://www.w3.org/Style/CSS/" target="_blank">CSS</a>.</p>
<p>Utilizalo es muy sencillo y más aun que existe una amplia variedad de<a href="http://www.noupe.com/jquery/50-amazing-jquery-examples-part1.html" target="_blank"> Widgets para el JQuery</a>. Puedes <a href="http://docs.jquery.com/Downloading_jQuery" target="_blank">descargar la librería de JQuery aquí</a>. Bien vemos cómo podemos utilizar esta librería y algunos ejemplos del JQuery.</p>
<p><span id="more-143"></span>Primero que nada invocamos al JQuery</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;JQuery&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script language=&quot;javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>La sintaxis de JQuery es muy sencilla, ya que siempre es igual y no hay mucha variedad. JQuery se reconoce cuando empezamos con el signo &#8220;$&#8221; (dólar). Por ejemplo</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>elemento<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">evento</span><span style="color: #009900;">&#40;</span>funcion<span style="color: #339933;">-</span>o<span style="color: #339933;">-</span>parametro<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Un ejemplo</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">//aquí escribimos algo...</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Como decia desde un principio, podemos utilizar la sintaxis de los CSS para saber a qué elementos del DOM estamos invocando. En este caso es para podas las etiquetas &#8220;img&#8221;.<br />
Podemos utilizar otras sintaxis como</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.logo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//Es para todas las etiquetas &quot;div&quot; donde su atributo &quot;class&quot; sea igual a &quot;logo&quot;</span>
     <span style="color: #006600; font-style: italic;">//aquí escribimos algo...</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.formulario input'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//Es para todas las etiquetas &quot;input&quot; dentro de las etiquetas &quot;div&quot; donde su atributo &quot;class&quot; sea igual a &quot;formulario&quot;</span>
     <span style="color: #006600; font-style: italic;">//aquí escribimos algo...</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Otras cosas que sorprendentes que vienen con la librería JQuery son los efectos muy fáciles de utilizar.</p>
<p><a href="http://www.giancarlospot.com/html_ajax/tabla_efectos_jquery.html?height=450&#038;width=900" title="Cuadro de efecto del JQuery" class="thickbox">Cuadro de efectos predeterminados del Jquery</a></p>
<p>Después que un efecto haya terminado podemos llamar a una función, por ejemplo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;div class=&quot;texto&quot; style=&quot;display: none; width: 320px; position: relative;&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Phasellus non erat. Sed magna. Sed congue sollicitudin dolor.
In luctus ligula ac neque. Sed nibh velit, euismod at, posuere a, feugiat eu, est.
Curabitur et eros. Sed vitae libero id ipsum accumsan congue.
Duis non risus vitae sem consequat iaculis. Cras volutpat justo vitae eros.
Mauris porttitor nulla eget erat. Cras condimentum volutpat ante.
Mauris fermentum metus id felis. Quisque at neque.
Vestibulum nulla magna, pulvinar sed, porttitor ut, viverra eget, libero.
Donec pretium. Quisque aliquam magna nec lectus rhoncus consequat. Suspendisse euismod.&lt;/div&gt;
&lt;script language=&quot;javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> DespuesSlideDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.texto'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>width<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span> top<span style="color: #339933;">:</span> <span style="color: #CC0000;">80</span><span style="color: #339933;">,</span> left<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> DespuesSlideUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.texto'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #339933;">,</span> DespuesSlideDown<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> DespuesFadeIn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.texto'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2000</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		setTimeout<span style="color: #009900;">&#40;</span>DespuesSlideUp<span style="color: #339933;">,</span> <span style="color: #CC0000;">2000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.texto'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">3000</span><span style="color: #339933;">,</span> DespuesFadeIn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><a href="http://www.giancarlospot.com/wp-content/uploads/empezando_con_jquery.zip">Descargar ejemplo &#8220;Empezando con Jquery&#8221;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/javascript/empezando-con-jquery.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>JSON &#8211; PHP y Javascript</title>
		<link>http://www.giancarlospot.com/php/json-php-y-javascript.html</link>
		<comments>http://www.giancarlospot.com/php/json-php-y-javascript.html#comments</comments>
		<pubDate>Wed, 18 Feb 2009 02:13:36 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://miblog.giancarlospot.com/?p=52</guid>
		<description><![CDATA[JSON, que significa &#8220;JavaScript Object Notation&#8221;, nos sirve para el intercambio de información entre diferentes lenguajes sin la necesidad de utilizar XML. &#8220;Es un subconjunto de la notación literal de objetos de JavaScript que no requiere el uso de XML&#8221;. Así como utilizamos XML para mandar información, JSON nos puede servir para lo mismo, solo [...]]]></description>
			<content:encoded><![CDATA[<p>JSON, que significa &#8220;JavaScript Object Notation&#8221;, nos sirve para el intercambio de información entre diferentes lenguajes sin la necesidad de utilizar XML. <a href="http://es.wikipedia.org/wiki/JSON" target="_blank">&#8220;Es un subconjunto de la notación literal de objetos de JavaScript que no requiere el uso de XML&#8221;</a>. Así como utilizamos XML para mandar información, JSON nos puede servir para lo mismo, solo que tiene otra estructura, más corta y, así poder mandar e interpretar información entre diferentes lenguajes de programación.</p>
<p><span id="more-52"></span><br />
Un ejemplo de cómo se ve un JSON es:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;titulo&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Título 1&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;descripcion&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Descripción 1&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;titulo&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Título 2&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;descripcion&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Descripción 2&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;titulo&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Título 3&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;descripcion&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Descripción 3&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span></pre></div></div>

<p>Para crear este código con PHP, desde la versión 5.2.6 es muy sencillo, ya que vienen las funciones json_encode y json_decode. La función &#8220;json_encode&#8221; convierte los arreglos en cadenas de texto en formato JSON y, el &#8220;json_decode&#8221; convierte cadenas de texto con formato JSON a arreglos, un ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #0000ff;">&quot;Título 1&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;descripcion&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;Descripción 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$arreglo</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;titulo&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;Título 2&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;descripcion&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;Descripción 2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$arreglo</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;titulo&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;Título 3&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;descripcion&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;Descripción 3&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arreglo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>Veamos un ejemplo en video:</p>
<div style="text-align: center;"><object width="445" height="364" data="http://www.youtube.com/v/b0UZzbltZG8&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01&amp;border=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/b0UZzbltZG8&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01&amp;border=1" /><param name="allowfullscreen" value="true" /></object></div>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/php/json-php-y-javascript.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ventana y Grilla con Ext</title>
		<link>http://www.giancarlospot.com/javascript/ventana-y-grilla-con-ext.html</link>
		<comments>http://www.giancarlospot.com/javascript/ventana-y-grilla-con-ext.html#comments</comments>
		<pubDate>Sun, 15 Feb 2009 22:59:51 +0000</pubDate>
		<dc:creator>giancarlo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[extjs]]></category>

		<guid isPermaLink="false">http://miblog.giancarlospot.com/?p=31</guid>
		<description><![CDATA[Crear una ventana flotante y una grilla con el framework, en javascript, de Extjs es muy sencillo. Todo esto lo explico con un video demostrativo. Descargar Paquete utilizado en el video]]></description>
			<content:encoded><![CDATA[<p>Crear una ventana flotante y una grilla con el framework, en <a href="http://www.giancarlospot.com/categoria/javascript">javascript</a>, de Extjs es muy sencillo. Todo esto lo explico con un video demostrativo.</p>
<p><span id="more-31"></span></p>
<div style="text-align: center;"><object width="445" height="364" data="http://www.youtube.com/v/c8lB1P1P7XI&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01&amp;border=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/c8lB1P1P7XI&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01&amp;border=1" /><param name="allowfullscreen" value="true" /></object></div>
<p><a href="http://www.giancarlospot.com/wp-content/uploads/ventana_grilla_ext.zip">Descargar Paquete utilizado en el video</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.giancarlospot.com/javascript/ventana-y-grilla-con-ext.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
