<?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>goran mitev &#187; jQuery</title>
	<atom:link href="http://goranmitev.com/category/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://goranmitev.com</link>
	<description>Freelance PHP/Ajax Web Developer and Wordpress Expert</description>
	<lastBuildDate>Tue, 10 May 2011 20:09:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Easiest &#8220;check all&#8221; with jQuery</title>
		<link>http://goranmitev.com/easiest-check-all-with-jquery</link>
		<comments>http://goranmitev.com/easiest-check-all-with-jquery#comments</comments>
		<pubDate>Thu, 13 Jan 2011 12:35:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://goranmitev.com/?p=239</guid>
		<description><![CDATA[The jquery code: &#60;script type="text/javascript"&#62; $(function () { $('.checkall').click(function () { $('.chk').attr('checked', this.checked); }); }); &#60;/script&#62; The html: &#60;input type="checkbox" class="checkall"/&#62; &#60;input type="checkbox" value="1" class="chk"/&#62; &#60;input type="checkbox" value="2" class="chk"/&#62; &#60;input type="checkbox" value="3" class="chk"/&#62; &#60;input type="checkbox" value="4" class="chk"/&#62;]]></description>
			<content:encoded><![CDATA[<p>The jquery code:</p>
<pre name="code" class="javascript">&lt;script type="text/javascript"&gt;
$(function () {
    $('.checkall').click(function () {
        $('.chk').attr('checked', this.checked);
    });
});
&lt;/script&gt;</pre>
<p>The html:</p>
<pre name="code" class="html">&lt;input type="checkbox" class="checkall"/&gt;
&lt;input type="checkbox" value="1" class="chk"/&gt;
&lt;input type="checkbox" value="2" class="chk"/&gt;
&lt;input type="checkbox" value="3" class="chk"/&gt;
&lt;input type="checkbox" value="4" class="chk"/&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://goranmitev.com/easiest-check-all-with-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 jQuery Performance Tips</title>
		<link>http://goranmitev.com/5-jquery-performance-tips</link>
		<comments>http://goranmitev.com/5-jquery-performance-tips#comments</comments>
		<pubDate>Sat, 13 Feb 2010 14:29:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.goranmitev.com/?p=12</guid>
		<description><![CDATA[In the world of Web 2.0 applications, speed is one of the most important things to take in mind. Every such web application often uses a large amount of JavaScript code which is run in the users&#8217; browser. Of course using a JavaScript library is essential to speed up the development of these applications, but [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of Web 2.0 applications, speed is one of the most important things to take in mind. Every such web application often uses a large amount of JavaScript code which is run in the users&#8217; browser. Of course using a JavaScript library is essential to speed up the development of these applications, but using it the wrong way exponentially decreases the execution speed of the code, so the application becomes very slow and unusable.</p>
<p>I&#8217;ve put together 5 performance tips for the most used JavaScript library, jQuery.<span id="more-12"></span></p>
<h3>1. Always get elements by #id</h3>
<p>This is the fastest selector in jQuery for finding the required element.</p>
<p>Always use it before tag selectors and class selectors. Ordered by speed:</p>
<ol>
<li>$(&#8220;#some-id&#8221;)</li>
<li>$(&#8220;div&#8221;)</li>
<li>$(&#8220;#some-id div&#8221;)</li>
<li>$(&#8220;#some-id div.some-class&#8221;)</li>
<li>$(&#8220;div.some-class&#8221;)</li>
<li>$(&#8220;.some-class&#8221;)</li>
</ol>
<h3>2. Minimize selection operations</h3>
<p>When using a loop, avoid selecting an element or elements in every iteration.</p>
<pre name="code" class="js">for (var i=0; i&lt;$("#table tr").length; i++){
 ...some code here...
}
</pre>
<p>Cache the selection like this:</p>
<pre name="code" class="js">var len = $("#table tr").length;
for (var i=0; i&lt;len; i++){
 ...some code here...
}</pre>
<h3>3. Insert one instead of many DOM elements</h3>
<p>Wrap all your code into one element and insert it in the DOM tree with the .html() method.</p>
<p>Instead of:</p>
<pre name="code" class="js">var html = '
 &lt;p&gt;One&lt;/p&gt;
 &lt;p&gt;Two&lt;/p&gt;
 &lt;div&gt;Three&lt;/div&gt;
';
$('#someid').html(html);</pre>
<p>Wrap the code in a div or other element, and then use the .html() method.</p>
<pre name="code" class="js">var html = '
&lt;div&gt;
 &lt;p&gt;One&lt;/p&gt;
 &lt;p&gt;Two&lt;/p&gt;
 &lt;div&gt;Three&lt;/div&gt;
&lt;/div&gt;
';
$('#someid').html(html);</pre>
<h3><strong>4. Give your selectors a context</strong></h3>
<p>As I said before, the fastest way to select elements is by #id, so, if you must use classes to select elements, give them a context.</p>
<p>Instead of:</p>
<pre name="code" class="js">$('.someclass').css('background-color' '#FFFFFF');</pre>
<p>Use this:</p>
<pre name="code" class="js">$('.someclass',#someclass-container).css('background-color' '#FFFFFF');</pre>
<h3><strong>5. Use jQuery chaining capabilities </strong></h3>
<p>One of the coolest things in jQuery is the possibility to chain your method calls. Example:</p>
<pre name="code" class="js">$('#someid').addClass('error').css('color','red').fadeOut('slow');</pre>
]]></content:encoded>
			<wfw:commentRss>http://goranmitev.com/5-jquery-performance-tips/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Delete a table row with jQuery</title>
		<link>http://goranmitev.com/delete-a-row-from-table-with-jquery</link>
		<comments>http://goranmitev.com/delete-a-row-from-table-with-jquery#comments</comments>
		<pubDate>Tue, 08 Dec 2009 09:14:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://goranmitev.ispraznise.com/?p=3</guid>
		<description><![CDATA[I will explain, shortly, how to delete a table row with jQuery Ajax post method. We will need some basic HTML example structure like the following: &#60;table&#62; &#60;tr&#62; &#60;td class='one'&#62;Text&#60;/td&#62;  &#60;td class='two'&#62;Some more text&#60;/td&#62;  &#60;td class='action'&#62;&#60;a style='cursor:pointer'&#62;delete&#60;/a&#62;&#60;/td&#62;  &#60;/tr&#62;  &#60;tr&#62;  &#60;td class='one'&#62;Text 2&#60;/td&#62;  &#60;td class='two'&#62;Some more text 2&#60;/td&#62;  &#60;td class='action'&#62;&#60;a style='cursor:pointer'&#62;delete&#60;/a&#62;&#60;/td&#62;  &#60;/tr&#62; &#60;/table&#62; And you want [...]]]></description>
			<content:encoded><![CDATA[<p>I will explain, shortly, how to delete a table row with jQuery Ajax post method. We will need some basic HTML example structure like the following:</p>
<pre name="code" class="html">
&lt;table&gt;
    &lt;tr&gt;
&lt;td class='one'&gt;Text&lt;/td&gt;
        &lt;td class='two'&gt;Some more text&lt;/td&gt;
        &lt;td class='action'&gt;&lt;a style='cursor:pointer'&gt;delete&lt;/a&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
        &lt;td class='one'&gt;Text 2&lt;/td&gt;
        &lt;td class='two'&gt;Some more text 2&lt;/td&gt;
        &lt;td class='action'&gt;&lt;a style='cursor:pointer'&gt;delete&lt;/a&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;/table&gt;
</pre>
<p>And you want to create a click event that deletes a row from a table, and in the same time sends a post or get request to a server that updates the database, deletes the row, you can do this with jQuery like this:</p>
<p><span id="more-3"></span></p>
<pre name="code" class="js">$(document).ready(function(){
    $('.action').click(function(){
       &lt;span style=&quot;color: #339966;&quot;&gt;//on click, mark the row for deleting by adding a class
       // 'deleting' to the tr element&lt;/span&gt;
       $(this).parent().addClass('deleting');

      &lt;span style=&quot;color: #339966;&quot;&gt; //make a post to the server, php script for example,
       // that deletes the row from a database&lt;/span&gt;
       $.post('deleteRow.php',{
             rowId: 2  &lt;span style=&quot;color: #339966;&quot;&gt;//send the row id for example&lt;/span&gt;
         },function(data){
             &lt;span style=&quot;color: #339966;&quot;&gt;//when the server is done with the deletion of the row
             // from the database, remove the element from the DOM tree&lt;/span&gt;
             $('.deleting').remove();
         })
      })
})
</pre>
<p>And that&#8217;s it. Any comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://goranmitev.com/delete-a-row-from-table-with-jquery/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

