<?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; javascript</title>
	<atom:link href="http://codepolice.net/tag/javascript/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>
	</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! -->