<?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>Codepolice.net &#187; JQuery</title>
	<atom:link href="http://codepolice.net/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepolice.net</link>
	<description>C#, ASP.NET, MVC, LINQ, Wordpress and stuff like that</description>
	<lastBuildDate>Mon, 26 Jul 2010 08:58:47 +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>Only show the sub menu when the parent is selected with the new wp_nav_menu in WordPress 3.0</title>
		<link>http://codepolice.net/2010/06/28/only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0/</link>
		<comments>http://codepolice.net/2010/06/28/only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 14:39:07 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[wordpress 3]]></category>
		<category><![CDATA[wp_nav_menu]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=296</guid>
		<description><![CDATA[I just spent two hours trying to hide the submenu for a menu item that is not selected in the new menu system in WordPress 3.0. First i found this post in the WordPress forums where someone had built a &#8220;Custom Walker&#8221; but it was for a slightly different scenario and it was also a [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent two hours trying to hide the submenu for a menu item that is not selected in the new menu system in WordPress 3.0. First i found <a href="http://wordpress.org/support/topic/413314">this post in the WordPress forums</a> where someone had built a &#8220;Custom Walker&#8221; but it was for a slightly different scenario and it was also a really complicated solution. Then i realized that i can do this super simple with jQuery. All you need is two lines of codes.</p>
<pre class="brush:javascript">$(document).ready(function () {
 $(".sub-menu").hide();
 $(".current_page_item .sub-menu, .current_page_parent .sub-menu").show();
 $(".sub-menu li").after("&lt;li class='sub-menu-seperator'&gt;|&lt;/li&gt;");
});</pre>
<p>This will hide all sub-menus, and then if a parent happens to have the class .current_page_item we show the sub-menu. My god i love jQuery.</p>
<p><strong>Update:</strong></p>
<p>As sushicodeur suggest you could of course do this only with CSS, it&#8217;s basically the same thing.</p>
<pre class="brush:css">.sub-menu { display: none; }
.current_page_item .sub-menu, .current_page_parent .sub-menu { display: block; }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2010/06/28/only-show-the-sub-menu-when-the-parent-is-selected-with-the-new-wp_nav_menu-in-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Convert all checked checkboxes into an comma seperated string with JQuery</title>
		<link>http://codepolice.net/2009/11/07/convert-all-checked-checkboxes-into-an-comma-seperated-string-with-jquery/</link>
		<comments>http://codepolice.net/2009/11/07/convert-all-checked-checkboxes-into-an-comma-seperated-string-with-jquery/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 15:30:00 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[checkboxes]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=178</guid>
		<description><![CDATA[Sometimes i just love jQuery. Well most of the time actually. I did some work for a client a couple of week ago and i needed get all checkoboxes that was checked as a comma seperated list. I started with this code. I found out about the &#8220;map&#8221; method of jQuery wich has the following [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes i just love jQuery. Well most of the time actually. I did some work for a client a couple of week ago and i needed get all checkoboxes that was checked as a comma seperated list. I started with this code. I found out about the &#8220;map&#8221; method of jQuery wich has the following description.</p>
<blockquote>
<div>Translate all items in an array to another array of items.</div>
<p>The translation function that is provided to this method is called for each item in the array and is passed two arguments: The the item to be translated, and index within the array.The function can then return the translated value, &#8216;null&#8217; (to remove the item), or an array of values &#8211; which will be flattened into the full array.</p></blockquote>
<p>The code i ended up with looked like this. Really really neat.</p>
<pre class="brush:js">
<input type="checkbox" value="1" class="chk" />
<input type="checkbox" value="2" class="chk" />
<input type="checkbox" value="3" class="chk" />
<input type="checkbox" value="4" class="chk" />
<input type="checkbox" value="5" class="chk" />
    <span id="show"></span>
    <script type="text/javascript">
        $(document).ready(function () {
            CheckSelected();
        });
        $('.chk').click(function () {
            CheckSelected();
        });
        function CheckSelected() {
            var idArray = $('.chk:checked').map(function () {
                return $(this).val();
            });
            $("#show").text($.makeArray(idArray).join(','));
        }
    </script></pre>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/11/07/convert-all-checked-checkboxes-into-an-comma-seperated-string-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET postback via JQuery / Javascript</title>
		<link>http://codepolice.net/2009/10/14/asp-net-postback-via-jquery-javascript/</link>
		<comments>http://codepolice.net/2009/10/14/asp-net-postback-via-jquery-javascript/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 11:35:04 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[webforms]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=172</guid>
		<description><![CDATA[ASP.NET Webforms isn&#8217;t the best platform to build web applications. I can&#8217;t wait to migrate my apps to ASP.NET MVC but until i have the time to do that i have to coup with some of asp.net strange parts. Today i wanted to invoke a postback via JQuery wich actually was fairly easy but i [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET Webforms isn&#8217;t the best platform to build web applications. I can&#8217;t wait to migrate my apps to ASP.NET MVC but until i have the time to do that i have to coup with some of asp.net strange parts.</p>
<p>Today i wanted to invoke a postback via JQuery wich actually was fairly easy but i wanted to write a small post about it.</p>
<p>The trick was to get the Javascript that asp.net call to do a postback, save it somewhere and then executed via the eval() method. I used a hidden form to store the postback script.</p>
<p><strong>In the asp.net file</strong></p>
<div class="codecolorer-container csharp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">hdnSearchPostBack<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> Page<span style="color: #008000;">.</span><span style="color: #0000FF;">ClientScript</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetPostBackEventReference</span><span style="color: #008000;">&#40;</span>SearchButton, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p><strong>In the js file</strong></p>
<div class="codecolorer-container csharp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">function<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> eval<span style="color: #008000;">&#40;</span>$<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;#ctl00_ctl00_hdnSearchPostBack&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">val</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></div>
<p>Simple as that!</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/10/14/asp-net-postback-via-jquery-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using JQuery Validation plugin with ASP.NET</title>
		<link>http://codepolice.net/2008/10/09/using-jquery-validation-plugin-with-aspnet/</link>
		<comments>http://codepolice.net/2008/10/09/using-jquery-validation-plugin-with-aspnet/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 13:42:53 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Form Validation]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://www.codepolice.net/?p=4</guid>
		<description><![CDATA[Like everyone else i&#8217;ve been playing around with JQuery alot latley. Asp.net and JQuery is not the best friends in the world but i guess it will be alot better when using ASP.NET MVC. Microsoft also annoncued that they will support JQuery natively in future versions. Nice! If you want to learn more about ASP.NET [...]]]></description>
			<content:encoded><![CDATA[<p>Like everyone else i&#8217;ve been playing around with JQuery alot latley. Asp.net and JQuery is not the best friends in the world but i guess it will be alot better when using ASP.NET MVC. Microsoft also annoncued that they will support <a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx" target="_blank">JQuery natively in future versions</a>. Nice!</p>
<p>If you want to learn more about ASP.NET and Jquery be sure to read both <a href="http://www.west-wind.com/Weblog/" target="_blank">Rick Sthral&#8217;s</a> and the <a href="http://encosia.com/" target="_blank">Encosia</a> blogs.</p>
<p>I&#8217;m working on a new project now where i am trying to stay away from asp.net ajax mainly because of performance reasons but also just because i want to learn something new. Today i&#8217;ve been using the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">JQuery Validation plugin</a>.</p>
<p>There is alot of documentation of how to use it on the the documentation pages for the plugin but i want to share with you one thing that i had problems with.</p>
<p>This is some regular example code that all the sample&#8217;s use. The problem here is that for example &#8220;EmailTextbox&#8221; is not the ID of the control but the name.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<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><br />
<span style="color: #006600; font-style: italic;">// validate signup form on keyup and submit</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#aspnetForm&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;rules<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;OpenIdTextbox<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;required&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;NicknameTextbox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remote<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;resources/nickname.aspx&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;EmailTextbox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; email<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>I scratched my head for a long long time when i used ctl00_ContentPlaceHolder1_EmailTextbox and nothing worked at all. So what you have to do is change this to something like this ..</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<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><br />
&nbsp;<span style="color: #006600; font-style: italic;">// validate signup form on keyup and submit</span><br />
&nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#aspnetForm&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;rules<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ctl00$ContentPlaceHolder1$OpenIdTextbox<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;required&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ctl00$ContentPlaceHolder1$NicknameTextbox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;remote<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;resources/nickname.aspx&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ctl00$ContentPlaceHolder1$EmailTextbox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;required<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;email<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp;<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>You could of course also use <a href="http://geekswithblogs.net/Gaurav/archive/2006/09/04/90195.aspx" target="_blank">some method that rewrite the Control.UniqueID to a name</a> and use &lt;%= %&gt; to get the name of the control.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2008/10/09/using-jquery-validation-plugin-with-aspnet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->