<?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>Nukium &#187; jQuery</title>
	<atom:link href="http://nukium.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://nukium.com</link>
	<description>Ressources et tutoriaux : Web 2.0 - PHP - CodeIgniter - Webdesign</description>
	<lastBuildDate>Tue, 15 May 2012 15:45:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>jScratchcard : Un plugin de grattage pour jQuery !</title>
		<link>http://nukium.com/javascript/jquery/jscratchcard-un-plugin-de-grattage-pour-jquery/</link>
		<comments>http://nukium.com/javascript/jquery/jscratchcard-un-plugin-de-grattage-pour-jquery/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 07:30:17 +0000</pubDate>
		<dc:creator>Nukium</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://nukium.com/?p=1091</guid>
		<description><![CDATA[jScratchcard est un plugin pour le framework JavaScript jQuery permettant de créer des zones grattables à la manière des jeux de grattages que l&#8217;on retrouve chez nos buralistes. Il devient alors possible d&#8217;imaginer la création de toutes sortes de jeux de grattages directement en HTML / CSS / jQuery (rappelons que ce type de jeux [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_silver" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fnukium.com%252Fjavascript%252Fjquery%252Fjscratchcard-un-plugin-de-grattage-pour-jquery%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22jScratchcard%20%3A%20Un%20plugin%20de%20grattage%20pour%20jQuery%20%21%22%20%7D);"></div>
<p><strong>jScratchcard</strong> est un <strong>plugin</strong> pour le <strong>framework JavaScript jQuery</strong> permettant de créer des <strong>zones grattables</strong> à la manière des <strong>jeux de grattages</strong> que l&#8217;on retrouve chez nos buralistes. Il devient alors possible d&#8217;imaginer la création de toutes sortes de <strong>jeux de grattages</strong> directement en <strong>HTML / CSS / jQuery</strong> (rappelons que ce type de jeux existe déjà sur le web en <strong>Flash</strong>).</p>
<p>Très simple d&#8217;utilisation, le <strong>plugin jScratchcard</strong> propose également une personnalisation des effets de grattage assez poussée. De quoi ravir les webmasters spécialisés dans le domaine !</p>
<p>En tout cas, félicitation à Senamion.com pour le plugin ! <img src='http://nukium.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <img class="alignright size-full wp-image-1092" title="jquery scratch plugin" src="http://www.nukium.com/wordpress/wp-content/uploads/2010/06/jquery-scratch-plugin.jpg" alt="jquery scratch plugin" width="200" height="100" /></p>
<p><a href="http://www.senamion.com/blog/jScratchcard.html">Voir la page de démonstration du plugin <strong>jScratchcard</strong>.</a></p>

 <p><a href="http://nukium.com/wordpress/?flattrss_redirect&amp;id=1091&amp;md5=13d91b7f85abf16807f57946a47e9aa8" title="Flattr" target="_blank"><img src="http://nukium.com/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://nukium.com/javascript/jquery/jscratchcard-un-plugin-de-grattage-pour-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=Kromack&amp;popout=1&amp;url=http%3A%2F%2Fnukium.com%2Fjavascript%2Fjquery%2Fjscratchcard-un-plugin-de-grattage-pour-jquery%2F&amp;language=fr_FR&amp;category=text&amp;title=jScratchcard+%3A+Un+plugin+de+grattage+pour+jQuery+%21&amp;description=jScratchcard+est+un+plugin+pour+le+framework+JavaScript+jQuery+permettant+de+cr%C3%A9er+des+zones+grattables+%C3%A0+la+mani%C3%A8re+des+jeux+de+grattages+que+l%26%238217%3Bon+retrouve+chez+nos+buralistes.+Il+devient...&amp;tags=JavaScript%2CjQuery%2Cplugin%2Cweb+2.0%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Tutoriel jQuery : appliquer un événement sur plusieurs éléments</title>
		<link>http://nukium.com/javascript/jquery/tutoriel-jquery-appliquer-un-evenement-sur-plusieurs-elements/</link>
		<comments>http://nukium.com/javascript/jquery/tutoriel-jquery-appliquer-un-evenement-sur-plusieurs-elements/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 10:52:47 +0000</pubDate>
		<dc:creator>Nukium</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://nukium.com/?p=921</guid>
		<description><![CDATA[Le contexte Imaginons que vous devez appliquer le même comportement d&#8217;événement à un ensemble d&#8217;éléments, il devient alors tout à fait naturel de créer une classe CSS qui permettra d&#8217;identifier tous les éléments et ainsi leur appliquer le comportement d&#8217;événement simultanément. Ceci ce traduirait par le code jQuery ci-dessous (notez que j&#8217;utilise jQuery à la [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_silver" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fnukium.com%252Fjavascript%252Fjquery%252Ftutoriel-jquery-appliquer-un-evenement-sur-plusieurs-elements%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Tutoriel%20jQuery%20%3A%20appliquer%20un%20%C3%A9v%C3%A9nement%20sur%20plusieurs%20%C3%A9l%C3%A9ments%22%20%7D);"></div>
<h2>Le contexte</h2>
<p>Imaginons que vous devez appliquer le même comportement d&#8217;événement à un ensemble d&#8217;éléments, il devient alors tout à fait naturel de créer une classe CSS qui permettra d&#8217;identifier tous les éléments et ainsi leur appliquer le comportement d&#8217;événement simultanément.</p>
<p>Ceci ce traduirait par le code<strong> jQuery</strong> ci-dessous (notez que j&#8217;utilise<strong> jQuery</strong> à la place de <strong>$</strong> pour des questions de compatibilité avec d&#8217;autres librairies) :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p921code3'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9213"><td class="code" id="p921code3"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.jQuery-elements-1'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">//traitement de l'événement</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Le problème</h2>
<p>Le code que nous venons de voir fonctionne bien, en revanche comment appliquer ce même comportement à un second ensemble d&#8217;éléments sans pour autant <strong>dupliquer de code</strong> ? Imaginons maintenant que nous possédons un second ensemble d&#8217;éléments portant pour une raison quelconque une classe CSS différente mais pour lequel nous désirons le même <strong>comportement d&#8217;événement</strong>.</p>
<p>La première solution qui vient à l&#8217;esprit consiste à dupliquer le code précédemment vu et à modifier <strong>la classe CSS utilisée</strong> pour pointer les éléments. C&#8217;est là qu&#8217;un peu d&#8217;astuce vas nous permettre d&#8217;éviter cette dupplication ! En effet, <strong>jQuery</strong> possède <strong>un puissant système de sélecteurs</strong> permettant de <strong>cibler des éléments HTML</strong>,en l&#8217;occurrence il suffira de <strong>séparer les deux classes CSS par une virgule</strong> pour appliquer le comportement d&#8217;événements à tous les éléments d&#8217;un seul coup !</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p921code4'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9214"><td class="code" id="p921code4"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.jQuery-elements-1, .jQuery-elements-2'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">//traitement de l'événement</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Pratique, n&#8217;est-ce pas ?</p>

 <p><a href="http://nukium.com/wordpress/?flattrss_redirect&amp;id=921&amp;md5=92f91b73dff65269a87e83f98392a895" title="Flattr" target="_blank"><img src="http://nukium.com/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://nukium.com/javascript/jquery/tutoriel-jquery-appliquer-un-evenement-sur-plusieurs-elements/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=Kromack&amp;popout=1&amp;url=http%3A%2F%2Fnukium.com%2Fjavascript%2Fjquery%2Ftutoriel-jquery-appliquer-un-evenement-sur-plusieurs-elements%2F&amp;language=fr_FR&amp;category=text&amp;title=Tutoriel+jQuery+%3A+appliquer+un+%C3%A9v%C3%A9nement+sur+plusieurs+%C3%A9l%C3%A9ments&amp;description=Le+contexte+Imaginons+que+vous+devez+appliquer+le+m%C3%AAme+comportement+d%26%238217%3B%C3%A9v%C3%A9nement+%C3%A0+un+ensemble+d%26%238217%3B%C3%A9l%C3%A9ments%2C+il+devient+alors+tout+%C3%A0+fait+naturel+de+cr%C3%A9er+une+classe+CSS+qui+permettra+d%26%238217%3Bidentifier...&amp;tags=ajax%2CJavaScript%2CjQuery%2CPHP%2Ctutoriel%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Insolite : jQuery Sliding Clock</title>
		<link>http://nukium.com/javascript/jquery/insolite-jquery-sliding-clock/</link>
		<comments>http://nukium.com/javascript/jquery/insolite-jquery-sliding-clock/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 19:12:48 +0000</pubDate>
		<dc:creator>Nukium</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[insolite]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://nukium.com/?p=859</guid>
		<description><![CDATA[jQuery Sliding Clock est une horloge numérique 2.0 propulsée par JavaScript via la librairie jQuery. C&#8217;est également une démonstration très originale des possibilités de ce framework !]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_silver" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fnukium.com%252Fjavascript%252Fjquery%252Finsolite-jquery-sliding-clock%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Insolite%20%3A%20jQuery%20Sliding%20Clock%22%20%7D);"></div>
<p><strong>jQuery Sliding Cloc</strong>k est une horloge numérique 2.0 propulsée par <strong>JavaScript</strong> via la librairie <strong>jQuery</strong>. C&#8217;est également une démonstration très originale des possibilités de ce framework !</p>
<p><a href="http://home.comcast.net/~vonholdt/test/clock_slide/index.htm"><img class="aligncenter size-full wp-image-860" title="jquery sliding clock" src="http://www.nukium.com/wordpress/wp-content/uploads/2010/01/jquery-clock.jpg" alt="" width="400" height="252" /></a></p>

 <p><a href="http://nukium.com/wordpress/?flattrss_redirect&amp;id=859&amp;md5=bf4cf8867d15385bcc7820444250629d" title="Flattr" target="_blank"><img src="http://nukium.com/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://nukium.com/javascript/jquery/insolite-jquery-sliding-clock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=Kromack&amp;popout=1&amp;url=http%3A%2F%2Fnukium.com%2Fjavascript%2Fjquery%2Finsolite-jquery-sliding-clock%2F&amp;language=fr_FR&amp;category=text&amp;title=Insolite+%3A+jQuery+Sliding+Clock&amp;description=jQuery+Sliding+Clock+est+une+horloge+num%C3%A9rique+2.0+propuls%C3%A9e+par+JavaScript+via+la+librairie+jQuery.+C%26%238217%3Best+%C3%A9galement+une+d%C3%A9monstration+tr%C3%A8s+originale+des+possibilit%C3%A9s+de+ce+framework+%21&amp;tags=insolite%2CJavaScript%2CjQuery%2Cweb+2.0%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Équivalence de la fonction MooTools $defined() sous jQuery</title>
		<link>http://nukium.com/javascript/jquery/equivalence-de-la-fonction-mootools-defined-sous-jquery/</link>
		<comments>http://nukium.com/javascript/jquery/equivalence-de-la-fonction-mootools-defined-sous-jquery/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 17:39:13 +0000</pubDate>
		<dc:creator>Nukium</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://nukium.com/?p=762</guid>
		<description><![CDATA[Dans mon récent apprentissage de l&#8217;excellente librairie JavaScript jQuery, j&#8217;ai cherché une équivalence de la fonction MooTools $defined() permettant de déterminer si un objet est défini ou non. Ce test est très pratique sous MooTools car il permet par exemple d&#8217;améliorer la généricité des scripts ou encore d&#8217;éviter d&#8217;appeler des objets non définis sur la [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_silver" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fnukium.com%252Fjavascript%252Fjquery%252Fequivalence-de-la-fonction-mootools-defined-sous-jquery%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22%C3%89quivalence%20de%20la%20fonction%20MooTools%20%24defined%28%29%20sous%20jQuery%22%20%7D);"></div>
<p>Dans mon récent apprentissage de l&#8217;excellente librairie <strong>JavaScript jQuery</strong>, j&#8217;ai cherché une équivalence de la <strong>fonction MooTools $defined()</strong> permettant de déterminer si un objet est défini ou non. Ce test est très pratique sous MooTools car il permet par exemple d&#8217;améliorer la généricité des scripts ou encore d&#8217;éviter d&#8217;appeler des objets non définis sur la page courante et ainsi provoquer une erreur.</p>
<p>Voici donc un exemple de <strong>code jQuery</strong> permettant de tester si l&#8217;élément HTML portant l&#8217;id &laquo;&nbsp;define&nbsp;&raquo; existe ou non. Si et seulement s&#8217;il existe, nous lui affecterons alors un événement click. Notez également l&#8217;utilisation de <em>preventDefault</em> permettant de stopper le comportement par défaut de l&#8217;événement, comme par exemple <strong>le scroll en haut de page lors du clic sur un lien</strong> :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p762code8'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7628"><td class="code" id="p762code8"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//If an HTML element with a &quot;define&quot; id exists :</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#define'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#define'</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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//We are stopping the default event like scrolling to the top of the page for a link</span>
		e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//Do some stuff here</span>
&nbsp;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


 <p><a href="http://nukium.com/wordpress/?flattrss_redirect&amp;id=762&amp;md5=f9cd3e681c3a79f789c720231c3e3cfd" title="Flattr" target="_blank"><img src="http://nukium.com/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://nukium.com/javascript/jquery/equivalence-de-la-fonction-mootools-defined-sous-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=Kromack&amp;popout=1&amp;url=http%3A%2F%2Fnukium.com%2Fjavascript%2Fjquery%2Fequivalence-de-la-fonction-mootools-defined-sous-jquery%2F&amp;language=fr_FR&amp;category=text&amp;title=%C3%89quivalence+de+la+fonction+MooTools+%24defined%28%29+sous+jQuery&amp;description=Dans+mon+r%C3%A9cent+apprentissage+de+l%26%238217%3Bexcellente+librairie+JavaScript+jQuery%2C+j%26%238217%3Bai+cherch%C3%A9+une+%C3%A9quivalence+de+la+fonction+MooTools+%24defined%28%29+permettant+de+d%C3%A9terminer+si+un+objet+est+d%C3%A9fini+ou+non.+Ce+test...&amp;tags=JavaScript%2CjQuery%2Cscript%2Ctutoriel%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Tutorial CodeIgniter : Flashdata Highlighting with jQuery and jGrowl</title>
		<link>http://nukium.com/developpement-php/codeigniter/tutorial-codeigniter-flashdata-highlighting-with-jquery-and-jgrowl/</link>
		<comments>http://nukium.com/developpement-php/codeigniter/tutorial-codeigniter-flashdata-highlighting-with-jquery-and-jgrowl/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 22:40:58 +0000</pubDate>
		<dc:creator>Nukium</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://nukium.com/?p=755</guid>
		<description><![CDATA[Tutorial pour CodeIgniter montrant comment créer facilement un système de notifications basé sur les Flashdata de CodeIgniter ainsi que le plugin jGrowl pour jQuery. Attention, ce tutoriel est en anglais ;)]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_silver" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fnukium.com%252Fdeveloppement-php%252Fcodeigniter%252Ftutorial-codeigniter-flashdata-highlighting-with-jquery-and-jgrowl%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Tutorial%20CodeIgniter%20%3A%20Flashdata%20Highlighting%20with%20jQuery%20and%20jGrowl%22%20%7D);"></div>
<div lang="en" xml:lang="en">
<img src="http://www.nukium.com/wordpress/wp-content/uploads/2009/12/growlicon.png" alt="growl icon" title="growl icon" width="128" height="128" class="alignright size-full wp-image-758" /><br />
This <strong>tutorial</strong> explain how to create a <strong>notification system</strong> based on the <strong>jGrowl plugin for jQuery</strong> and the <strong>CodeIgniter session Flashdata</strong>.</p>
<p>Basically, Flashdata are sessions data only available for the next server request and are then automatically removed. This class can easily be used to build a simple <strong>notification system</strong> for your application.</p>
<h2>Step 1: Create a Flashdata</h2>
<p>In order to use CodeIgniter flashdata, we need to load the session library. Then, the <code>set_flashdata</code> method allows to set a session flashdata. This code has to be placed in your controller.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p755code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75510"><td class="code" id="p755code10"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'result'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'This is a custom notification using jGrowl and a Flashdata.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Step 2: Display the Flashdata</h2>
<p>I assume that you are using a header view file that is loaded in first everywhere in your application. Just add the code below that test if the flashdata var named result is set, then write the jQuery code that lauch the jGrowl notification.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p755code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75511"><td class="code" id="p755code11"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'result'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;!--</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>ready<span style="color: #009900;">&#40;</span><span style="color: #000000; 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: #339933;">.</span>jGrowl<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$this-&gt;session</span>-&gt;flashdata('result') ?&gt;&quot;</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: #666666; font-style: italic;">//--&gt;				</span>
	<span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>Step 3: Install the jGrowl plugin for jQuery</h2>
<p>The code above can&#8217;t work without adding the <strong>JavaScript notification files</strong>. You just have to add the <strong>jQuery library</strong> and the <strong>jGrowl plugin</strong> files into your header, don&#8217;t forget the <strong>jGrowl CSS file</strong> too. These files can be <a href="http://plugins.jquery.com/files/jGrowl-1.2.4.zip">dowloaded here</a> or on the <a href="http://stanlemon.net/projects/jgrowl.html">jGrowl project home page</a>.</p>
<h2>Step 4: View demo!</h2>
<p>The live demo is available on my demos space: <a href="http://demos.nukium.com/codeigniter-jgrowl-notifications-flashdata-jquery">CodeIgniter Flashdata Highlighting with jQuery and jGrowl demonstration</a>.
</div>

 <p><a href="http://nukium.com/wordpress/?flattrss_redirect&amp;id=755&amp;md5=60b4f9354fa440f8e3192d4023b84d40" title="Flattr" target="_blank"><img src="http://nukium.com/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://nukium.com/developpement-php/codeigniter/tutorial-codeigniter-flashdata-highlighting-with-jquery-and-jgrowl/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=Kromack&amp;popout=1&amp;url=http%3A%2F%2Fnukium.com%2Fdeveloppement-php%2Fcodeigniter%2Ftutorial-codeigniter-flashdata-highlighting-with-jquery-and-jgrowl%2F&amp;language=fr_FR&amp;category=text&amp;title=Tutorial+CodeIgniter+%3A+Flashdata+Highlighting+with+jQuery+and+jGrowl&amp;description=This+tutorial+explain+how+to+create+a+notification+system+based+on+the+jGrowl+plugin+for+jQuery+and+the+CodeIgniter+session+Flashdata.+Basically%2C+Flashdata+are+sessions+data+only+available+for+the...&amp;tags=CodeIgniter%2CJavaScript%2CjQuery%2Cmodule%2CPHP%2Cplugin%2Ctutoriel%2Cblog" type="text/html" />
	</item>
	</channel>
</rss>

