<?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>Intelligrape  Groovy &#38; Grails Blogs &#187; Javascript/Ajax/JQuery</title>
	<atom:link href="http://www.intelligrape.com/blog/category/javascript-ajax-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.intelligrape.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 07:48:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Intelligrape  Groovy &amp; Grails Blogs</title>
			<url>http://www.intelligrape.com/blog/wp-content/uploads/2011/05/favicon2.ico</url>
			<link>http://www.intelligrape.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>Detecting mobile browsers in Javascript</title>
		<link>http://www.intelligrape.com/blog/2011/12/18/detecting-mobile-browsers-in-javascript/</link>
		<comments>http://www.intelligrape.com/blog/2011/12/18/detecting-mobile-browsers-in-javascript/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 14:11:12 +0000</pubDate>
		<dc:creator>Vishal Sahu</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[detect mobile browser]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[mobile browser]]></category>
		<category><![CDATA[mobile detection]]></category>
		<category><![CDATA[redirect for mobile browser]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=4772</guid>
		<description><![CDATA[Hi,
In my recent grails project, i was working on mobile version of the application and needed to redirect users to the mobile version of our application, if they are accessing the application from any mobile device. I looked at various techniques/codes to detect mobile device and redirect users to the specific URL.


I encountered a simplest [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>In my recent grails project, i was working on mobile version of the application and needed to redirect users to the mobile version of our application, if they are accessing the application from any mobile device. I looked at various techniques/codes to detect mobile device and redirect users to the specific URL.</p>
<pre>
</pre>
<p>I encountered a simplest piece of code which worked in my case and thought it worth sharing. </p>
<pre>
</pre>
<p>Just put this code in the head section of you web page and it will redirect it to the specified URL if the device is mobile browser.</p>
<p>Code is:</p>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot;&gt;

if (screen.width &lt;= 699) {
document.location = &quot;http://www.example.com/mobile-version.html&quot;;
}

&lt;/script&gt;
</pre>
<pre>
</pre>
<p>References:-<br />
<a href="http://css-tricks.com/snippets/javascript/redirect-mobile-devices/">http://css-tricks.com/snippets/javascript/redirect-mobile-devices</a><br />
<a href="http://www.ianfernando.com/2011/how-to-redirect-mobile-traffic-to-a-mobile-friendly-page/">http://www.ianfernando.com/2011/how-to-redirect-mobile-traffic-to-a-mobile-friendly-page/</a><br />
<a href="http://www.warriorforum.com/offline-marketing-discussions/376351-redirection-script-mobile-site.html">http://www.warriorforum.com/offline-marketing-discussions/376351-redirection-script-mobile-site.html</a></p>
<pre>
</pre>
<p>This worked for me.<br />
Hope it helps.</p>
<pre>
</pre>
<p>Cheers!!!<br />
Vishal Sahu<br />
vishal@intelligrape.com<br />
<a href="http://www.intelligrape.com">http://www.intelligrape.com</a><br />
<a href="http://www.linkedin.com/in/vishalsahu"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/12/18/detecting-mobile-browsers-in-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Placeholder in html5</title>
		<link>http://www.intelligrape.com/blog/2011/05/15/placeholder-in-html5/</link>
		<comments>http://www.intelligrape.com/blog/2011/05/15/placeholder-in-html5/#comments</comments>
		<pubDate>Sun, 15 May 2011 14:00:41 +0000</pubDate>
		<dc:creator>umar</dc:creator>
				<category><![CDATA[HTML-UI-CSS]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[placeholder]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3790</guid>
		<description><![CDATA[HTML5 has made the page designing an easy task. Placeholder is input field improvement in html5. Things that we were doing in past using combination of HTML and client side scripting language can be done in HTML5  using an attribute. One of the example is placeholder attribute used with input type text which automatically [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 has made the page designing an easy task. Placeholder is input field improvement in html5. Things that we were doing in past using combination of HTML and client side scripting language can be done in HTML5  using an attribute. One of the example is placeholder attribute used with input type text which automatically puts the placeholder attribute value in the text field if it is empty. This placeholder text is cleared automatically on focus and on focus out either the entered text or the placeholder value (if nothing was entered) is displayed.</p>
<p><strong>html form</strong></p>
<pre class="brush: groovy;">
&lt;form&gt;
&lt;code&gt;
  &lt;input name=&quot;fieldname&quot; placeholder=&quot;Enter any keyword&quot;&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Search&quot;&gt;
&lt;/code&gt;
&lt;/form&gt;
</pre>
<p><strong>Support browser</strong></p>
<table style="border-spacing: 1px;border-collapse: inherit;font-size: 12px;font-family: Arial,Helvetica,sans-serif,'Arial Rounded MT Bold'" cellspacing="1" cellpadding="4" width="100%" bgcolor="#cccccc">
<tbody>
<tr>
<td width="100" bgcolor="#e6e6e6"><strong>IE</strong></td>
<td width="100" bgcolor="#e6e6e6"><strong> Firefox </strong></td>
<td width="100" bgcolor="#e6e6e6"><strong>Safari </strong></td>
<td width="100" bgcolor="#e6e6e6"><strong>Chrome</strong></td>
<td width="100" bgcolor="#e6e6e6"><strong> Opera</strong></td>
</tr>
<tr>
<td bgcolor="#ffffff">.</td>
<td bgcolor="#ffffff">3.7+</td>
<td bgcolor="#ffffff">4.0+</td>
<td bgcolor="#ffffff">4.0+</td>
<td bgcolor="#ffffff">11.0+</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/05/15/placeholder-in-html5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JQuery : create URL query string from JSON/Array</title>
		<link>http://www.intelligrape.com/blog/2011/05/04/jquery-create-url-query-string-from-jsonarray/</link>
		<comments>http://www.intelligrape.com/blog/2011/05/04/jquery-create-url-query-string-from-jsonarray/#comments</comments>
		<pubDate>Wed, 04 May 2011 06:46:45 +0000</pubDate>
		<dc:creator>Amit Jain</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[querystring]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3761</guid>
		<description><![CDATA[Hi Friends,

I was writing javascript to reload my page with different parameters. So I needed to create the queryString of those parameters but I didn&#8217;t want to create it of my own. I already knew about jQuery.serialize() which serializes the form and creates the queryString, but unfortunately I didn&#8217;t have form. So that gave me [...]]]></description>
			<content:encoded><![CDATA[<p>Hi Friends,<br />
<span id="more-3761"></span><br />
I was writing javascript to reload my page with different parameters. So I needed to create the queryString of those parameters but I didn&#8217;t want to create it of my own. I already knew about <a href="http://api.jquery.com/serialize/">jQuery.serialize()</a> which serializes the form and creates the queryString, but unfortunately I didn&#8217;t have form. So that gave me opportunity to learn about new <a href="http://api.jquery.com/jQuery.param/">jQuery.param()</a> which converts the JSON/Array into query string. Let us look at few examples below :</p>
<pre class="brush: jscript;">
var myParams = {country:&quot;US&quot;, customerId:&quot;1&quot;}
jQuery.param(myParams);

Output: &quot;country=US&amp;customerId=1&quot;
</pre>
<pre class="brush: jscript;">
var myParams = {name: &quot;Amit Jain&quot;,days:['Mon','Tue','Sat'] };
jQuery.param(myParams);

Output: &quot;name=Amit+Jain&amp;days%5B%5D=Mon&amp;days%5B%5D=Tue&amp;days%5B%5D=Sat&quot;
</pre>
<pre class="brush: jscript;">
var myParams = {name: &quot;Diana&quot;,address:{
  line1:&quot;232 Alder Dr.&quot;,
  line2:&quot;Alder City&quot;,
  state : &quot;Utah&quot;,
  country: &quot;US&quot;
}};
jQuery.param(myParams);

Output : &quot;name=Diana&amp;address%5Bline1%5D=232+Alder+Dr.&amp;address%5Bline2%5D=Alder+City&amp;address%5Bstate%5D=Utah&amp;address%5Bcountry%5D=US&quot;
</pre>
<p>Hope this helped!<br />
<!--more--><br />
Cheers!</p>
<p>~~Amit Jain~~<br />
amit@intelligrape.com</p>
<p>http://www.intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/05/04/jquery-create-url-query-string-from-jsonarray/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Change Input Type auto focus</title>
		<link>http://www.intelligrape.com/blog/2011/03/15/change-input-type-auto-focus/</link>
		<comments>http://www.intelligrape.com/blog/2011/03/15/change-input-type-auto-focus/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 03:14:22 +0000</pubDate>
		<dc:creator>umar</dc:creator>
				<category><![CDATA[HTML-UI-CSS]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3375</guid>
		<description><![CDATA[This is little bit but it is very useful. This is input type equalto text when when cursor come in input then change type equalto password.
Embed in html

&#60;input type=&#34;text&#34; onblur=&#34;javascript:if(this.value==''){this.value='password',this.type='text'} else {this.type='password'}&#34; onfocus=&#34;javascript:if(this.value=='password'){this.value=''} {this.type='password'}&#34; value=&#34;password&#34; tabindex=&#34;1&#34; size=&#34;30&#34; id=&#34;txtEmail&#34; name=&#34;txtEmail&#34;&#62;

This is Demo 




Support browser



IE
 Firefox 
Safari 
Chrome
 Opera


6.0+
3.5+
3.0+
3.0+
10.5+



]]></description>
			<content:encoded><![CDATA[<p>This is little bit but it is very useful. This is input type equalto text when when cursor come in input then change type equalto password.</p>
<p><strong>Embed in html</strong></p>
<pre class="brush: java;">
&lt;input type=&quot;text&quot; onblur=&quot;javascript:if(this.value==''){this.value='password',this.type='text'} else {this.type='password'}&quot; onfocus=&quot;javascript:if(this.value=='password'){this.value=''} {this.type='password'}&quot; value=&quot;password&quot; tabindex=&quot;1&quot; size=&quot;30&quot; id=&quot;txtEmail&quot; name=&quot;txtEmail&quot;&gt;
</pre>
<p><strong>This is Demo </strong><br />
<code></p>
<input type="text" onblur="javascript:if(this.value==''){this.value='password',this.type='text'} else {this.type='password'}" onfocus="javascript:if(this.value=='password'){this.value=''} {this.type='password'}" class="comment-pad5" value="password" tabindex="1" size="30" id="txtEmail" name="txtEmail">
</code><br />
<br/><br />
<strong>Support browser</strong></p>
<table style="border-spacing: 1px; border-collapse: inherit; font-size: 12px; font-family: Arial,Helvetica,sans-serif,'Arial Rounded MT Bold';" cellspacing="1" cellpadding="4" width="100%" bgcolor="#cccccc">
<tbody>
<tr>
<td width="100" bgcolor="#e6e6e6"><strong>IE</strong></td>
<td width="100" bgcolor="#e6e6e6"><strong> Firefox </strong></td>
<td width="100" bgcolor="#e6e6e6"><strong>Safari </strong></td>
<td width="100" bgcolor="#e6e6e6"><strong>Chrome</strong></td>
<td width="100" bgcolor="#e6e6e6"><strong> Opera</strong></td>
</tr>
<tr>
<td bgcolor="#ffffff">6.0+</td>
<td bgcolor="#ffffff">3.5+</td>
<td bgcolor="#ffffff">3.0+</td>
<td bgcolor="#ffffff">3.0+</td>
<td bgcolor="#ffffff">10.5+</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/03/15/change-input-type-auto-focus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorting in javascript</title>
		<link>http://www.intelligrape.com/blog/2011/03/13/sorting-in-javascript/</link>
		<comments>http://www.intelligrape.com/blog/2011/03/13/sorting-in-javascript/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 17:47:40 +0000</pubDate>
		<dc:creator>Sachin</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3281</guid>
		<description><![CDATA[Recently in my project I needed to sort an object list on the basis of object name. For the same purpose I created the following function


function sortList(objList) {
 objList.sort(sortByName);
}

function sortByName(a, b) {
 var x = a.name;
 var y = b.name;
 return ((x &#60; y) ? -1 : ((x &#62; y) ? 1 : 0));
}

This function [...]]]></description>
			<content:encoded><![CDATA[<p>Recently in my project I needed to sort an object list on the basis of object name. For the same purpose I created the following function</p>
<pre class="brush: java;">

function sortList(objList) {
 objList.sort(sortByName);
}

function sortByName(a, b) {
 var x = a.name;
 var y = b.name;
 return ((x &lt; y) ? -1 : ((x &gt; y) ? 1 : 0));
}
</pre>
<p>This function sorts an object list on the basis of name of object. Hope it helps</p>
<p>Sachin Anand</p>
<p>sachin[at]intelligrape[dot]com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/03/13/sorting-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Google Analytics for tracking Multiple Steps of a Webflow</title>
		<link>http://www.intelligrape.com/blog/2011/02/28/using-google-analytics-for-tracking-multiple-steps-of-a-webflow/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/28/using-google-analytics-for-tracking-multiple-steps-of-a-webflow/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 08:35:23 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[Google Web Tools]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3166</guid>
		<description><![CDATA[In one of our projects, we are using a webflow for an order wizard. We needed to track the number of users converting a draft to a confirmed order using Google Analytics. This would have been simple if the URLs were different for each step. However, that is not the way webflows work and a [...]]]></description>
			<content:encoded><![CDATA[<p>In one of our projects, we are using a webflow for an order wizard. We needed to track the number of users converting a draft to a confirmed order using Google Analytics. This would have been simple if the URLs were different for each step. However, that is not the way webflows work and a similar URL is generated for multiple steps. After some searching around, we found that we could call a trackPageView method in Google Analytics API and set a name for the page being tracked. This could be done using</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
    try {
        var pageTracker = _gat._getTracker(&quot;&lt;ANALYTICS-KEY&gt;&quot;);
        pageTracker._trackPageview(&quot;/enterDetails.html&quot;);
    } catch(err) {
    }
&lt;/script&gt;
</pre>
<p>Replacing &#8220;/enterDetails.html&#8221; in each page with the corresponding step name did the trick. However, this is an old version of the Google Analytics API. Our application uses a newer version of the JavaScript code provided by Google.</p>
<p>In this, we had to use Virtual Page Tracking, which is a method explained in the <a href="http://code.google.com/apis/analytics/docs/tracking/asyncMigrationExamples.html" target="_blank">Google Analytics API Docs</a> under the section, Virtual Page Views. We had to write something like</p>
<pre class="brush: jscript;">

&lt;script type=&quot;text/javascript&quot;&gt;
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'ANALYTICS-KEY']);
_gaq.push(['_trackPageview', '/enterDetails.html']);
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
&lt;/script&gt;
</pre>
<p>For usage on grails, we used a template, which takes in the pageName and uses /${controllerName}/${actionName}/${pageName} to  generate the virtual page name which is tracked. Now we are successfully tracking the conversions.</p>
<p>Hope this helps.</p>
<p>Vivek</p>
<p>http://in.linkedin.com/in/svivekkrishna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/28/using-google-analytics-for-tracking-multiple-steps-of-a-webflow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Editable Label Tag and introduction to Effects Tag Lib</title>
		<link>http://www.intelligrape.com/blog/2011/02/19/editable-label-tag-and-introduction-to-effects-tag-lib/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/19/editable-label-tag-and-introduction-to-effects-tag-lib/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 12:21:19 +0000</pubDate>
		<dc:creator>Kushal Likhi</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[HTML-UI-CSS]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[lable]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tag lib]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3095</guid>
		<description><![CDATA[Lately i had some spare time, hence decided to utilise it for developing some cool GUI elements.

What is effects tag lib??
It is just a new tag lib which is intended to contain some cool grails tags for GUI manipulations.
new tags will be added to it on timely basis, this is the first post regarding this [...]]]></description>
			<content:encoded><![CDATA[<p>Lately i had some spare time, hence decided to utilise it for developing some cool GUI elements.<br />
</p>
<h2>What is effects tag lib??</h2>
<p>It is just a new tag lib which is intended to contain some cool grails tags for GUI manipulations.<br />
new tags will be added to it on timely basis, this is the first post regarding this tag lib.<br />
</p>
<h2>Editable Lable</h2>
<p>this is the first tag in this tag lib. It is a cool GUI label which can be edited realtime.<br />
<br />
<strong><em>Features:</em></strong><br />
1) Post-able as a form element.<br />
2) easy value manipulation and extraction.<br />
3) Tool Tip support.<br />
4) Validate-able using, just assign class as you assign to any text field for validation.<br />
5) style-able using css<br />
6) Default value and blank handling<br />
7) easy to use.<br />
<br />
<strong>Details about the tag</strong><br />
tag usage:-<br />
</p>
<h3>&lt;etl:editableLable /&gt;</h3>
<p><b>you can treat this tag as an input text field, it gives you similar behaviour</b><br />
<br />
attributes:<br />
1) <strong>name:</strong> for form support, the value is posted with the form with param.<name><br />
2) <strong>class:</strong> class to be applied, for styling and validation.<br />
3)<strong> id:</strong> id given to the input feild<br />
4) <strong>value:</strong> value to be displayed on the lable<br />
5) <strong>default:</strong> the value to be displayed in case user enters blank in the edit mode<br />
6) <strong>size:</strong> the size of the input feild<br />
7) <strong>tooltip:</strong> text to be displayed in tool tip. if nothing specified default tooltip text will be displayed. i.e. &#8220;click to edit&#8221;<br />
8] <strong>tooltipclass:</strong> class assigned for styling the tooltip as per the page needs<br />
<strong>NOTE:</strong> All attributes are <b>not</b> required.<br />
</p>
<h1>DEMO:-</h1>
<p>here is the demo to the tag:<br />
<iframe src="http://www.kushal.likhi.me/demo/effectsTagLib-editableLabel.html" width="700px" height="280px" style="border:none" scroll="0"></iframe></p>
<h2>Next Addition</h2>
<p># Image scroller filmstrip tag<br />
# vertical image slider tag<br />
# Editable paragraph tag<br />
# safe string tag<br />
# Drawable rounded border without images tag<br />
# auto sizing-resizing tag<br />
# relative positioning<br />
# image slider normal<br />
# picker tab(3X3) tag<br />
# tool tip provider tag<br />
# progress bar tag<br />
# slider tag<br />
# modal window<br />
# modless window<br />
# progress bar<br />
# more/less box<br />
# pie graph<br />
# bar graph<br />
keep looking&#8230;&#8230;&#8230;<br />
</p>
<h2>Download: </h2>
<p>Link coming soon!! within few days.. waiting for some more tags to be completed.<br />
<br />
Regards<br />
Kushal Likhi<br />
www.intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/19/editable-label-tag-and-introduction-to-effects-tag-lib/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>File Uploading using plupload plugin of jquery.</title>
		<link>http://www.intelligrape.com/blog/2011/02/14/file-uploading-using-plupload-plugin-of-jquery/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/14/file-uploading-using-plupload-plugin-of-jquery/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 12:50:10 +0000</pubDate>
		<dc:creator>Anuj Aneja</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=2798</guid>
		<description><![CDATA[In my grails project i was having the requirement of having multiple file uploading, but in current implementation there was the problem of button being not loaded in Internet Explorer.For that i found plupload very cool to implement this. It has very cool feature of drag and drop and support for almost all browser. Actually [...]]]></description>
			<content:encoded><![CDATA[<p>In my grails project i was having the requirement of having multiple file uploading, but in current implementation there was the problem of button being not loaded in Internet Explorer.For that i found plupload very cool to implement this. It has very cool feature of drag and drop and support for almost all browser. Actually what it does is based on the browser, get the Runtime of the browser.For Documentation, js and css refer <a href="http://www.plupload.com/index.php">link</a></p>
<p>In gsp we need to include the js of pluplaod api as shown below:</p>
<pre class="brush: jscript;">
&lt;link rel=&quot;stylesheet&quot; href=&quot;${resource(dir: 'css/plupload/css', file: 'plupload.queue.css')}&quot; type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;${resource(dir: 'css/plupload/css', file: 'jquery.ui.plupload.css')}&quot; type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
&lt;g:set var=&quot;fileExtension&quot; value=&quot;${new FileExtension()}&quot;&gt;&lt;/g:set&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;p:javascript src='jquery-1.3.2'/&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;gears_init.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;browserplus-min.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;!-- Load source versions of the plupload script files --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.gears.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.silverlight.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.flash.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.browserplus.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.html5.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;jquery.plupload.queue.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    var button = '${buttonId}';
&lt;/script&gt;
</pre>
<p>Now we need to write script to load and bind the plupload plugin shown below:</p>
<pre class="brush: jscript;">
	&lt;script type=&quot;text/javascript&quot;&gt;
    var runtimesList;
    if (navigator.userAgent.indexOf(&quot;Firefox&quot;)!=-1){
        runtimesList='silverlight,browserplus,html4,gears,flash,html5';
    }else{
        runtimesList='html5,silverlight,browserplus,html4,gears,flash';
    }
    $(function() {
        var uploader = new plupload.Uploader({
            runtimes : runtimesList,
            browse_button : 'pickfiles',
            url : url,
            flash_swf_url : '${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.flash.swf&quot;)}',
            silverlight_xap_url : '${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.silverlight.xap&quot;)}',
            filters : [
                {title : &quot;Image files&quot;, extensions : &quot;gif,png&quot;},
                {title : &quot;Zip files&quot;, extensions : &quot;zip&quot;}
            ]
        });

        uploader.bind('Init', function(up, params) {
        });

        uploader.bind('FilesAdded', function(up, files) {
            $.each(files, function(i, file) {
                $('#filelist').append('&lt;div id=&quot;' + file.id + '&quot;&gt;&lt;span class=&quot;mcentd9d&quot; style=&quot;font-size:12px; color:green;&quot;&gt;File: ' + file.name + ' uploaded successfully!(' + plupload.formatSize(file.size) + ')&lt;b&gt;&lt;/b&gt;&lt;\/span&gt;' + '&lt;/div&gt;');
            });
        });

        uploader.bind('UploadFile', function(up, file) {

        });

        uploader.bind('UploadProgress', function(up, file) {
            $('#' + file.id + &quot; b&quot;).html(file.percent + &quot;%&quot;);
        });

        uploader.bind('QueueChanged', function(up) {
            $('#uploadfiles').click();
        });

        uploader.bind('FileUploaded', function(up) {

        });
        uploader.bind('Error', function(up) {
            alert('Error in uploading file');
        });

        $('#uploadfiles').click(function(e) {
            uploader.start();
            e.preventDefault();
        });
        uploader.init();
    });

&lt;/script&gt;
	&lt;div class=&quot;attachment&quot;&gt;
               &lt;div id=&quot;filelist&quot;&gt;&lt;/div&gt;
                      &lt;a href=&quot;#&quot; class=&quot;plupload_button plupload_add&quot; id=&quot;pickfiles&quot; style=&quot;position: relative; z-index: 0; &quot;&gt;Select File&lt;/a&gt;
                      &lt;input type='hidden' id=&quot;uploadfiles&quot;/&gt;
          &lt;/div&gt;
</pre>
<p>Now we need to handle the saving part of the file,for each file uploaded in Queue there is separate call to<br />
the action.It saves the file to the filePath specified.</p>
<pre class="brush: java;">
def saveAttachment={
      def files = request.getFileMap()
      def file=files.get(&quot;file&quot;)
      String fileName = file.getOriginalFilename()
      byte[] data=file.getBytes()
      File dir=new File(filePath)//some path...
      if(!dir.exists()){
         dir.mkdirs()
      }
      File actualFile=new File(filePath, fileName)
      actualFile.withOutputStream {out -&gt;
             out.write data
      }
}
</pre>
<p>Disclaimer: As in some cases you might want to can the upload of all the files as there is a different call to action of you can save there files in session, but session for this plupload is different from current user session so you will have to make your own session handling for that!!!</p>
<p>Note:The total length of files upload and and total uploaded differs in case IE and Firefox. The comments and any suggestions are welcomed.</p>
<p>Hope it help you guys! Cheer! <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anuj Aneja</p>
<p>http://www.Intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/14/file-uploading-using-plupload-plugin-of-jquery/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>JQGrid Expanding SubGrid on page load</title>
		<link>http://www.intelligrape.com/blog/2011/02/13/jqgrid-expanding-subgrid-on-page-load/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/13/jqgrid-expanding-subgrid-on-page-load/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 14:08:34 +0000</pubDate>
		<dc:creator>Tarun Pareek</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JQuery JQGrid Plugin]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=2784</guid>
		<description><![CDATA[Hi,
&#160;
Recently guys, i faced problem while expanding the JQGrid SubGrid onLoad of the page.
&#160;
Initially, i used the following code on gridComplete Event of JQGrid, Using the code given below, i am only able to expand grid but without data populated in subgrid.


gridComplete: function&#40;&#41; &#123;
            [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
&nbsp;<br />
Recently guys, i faced problem while expanding the JQGrid SubGrid onLoad of the page.<br />
&nbsp;<br />
Initially, i used the following code on gridComplete Event of JQGrid, Using the code given below, i am only able to expand grid but without data populated in subgrid.<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="groovy">gridComplete: function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                var rowIds <span style="color: #66cc66;">=</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDataIDs</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                $.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span>rowIds, function <span style="color: #66cc66;">&#40;</span>index, rowId<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">expandSubGridRow</span><span style="color: #66cc66;">&#40;</span>rowId<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>                   
                <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>After trying different ways, and many efforts i came up with this <strong>solution</strong> and it worked for me.<br />
Solution to above problem given below :<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="groovy">gridComplete: function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                var timeOut <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">50</span><span style="color: #66cc66;">;</span>
                var rowIds <span style="color: #66cc66;">=</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDataIDs</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                $.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span>rowIds, function <span style="color: #66cc66;">&#40;</span>index, rowId<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    setTimeout<span style="color: #66cc66;">&#40;</span>function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">expandSubGridRow</span><span style="color: #66cc66;">&#40;</span>rowId<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                    <span style="color: #66cc66;">&#125;</span>, timeOut<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                    timeOut <span style="color: #66cc66;">=</span> timeOut + <span style="color: #cc66cc;">200</span><span style="color: #66cc66;">;</span>
                <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>It worked for me. Hope it help you too.<br />
<br/></p>
<p>Thanks &#038; regards,<br />
Tarun Pareek<br />
<a href="http://in.linkedin.com/in/tarunpareek">LinkedIn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/13/jqgrid-expanding-subgrid-on-page-load/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Grails taglib and JavaScript file</title>
		<link>http://www.intelligrape.com/blog/2011/01/16/grails-taglib-and-javascript-file/</link>
		<comments>http://www.intelligrape.com/blog/2011/01/16/grails-taglib-and-javascript-file/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 16:07:16 +0000</pubDate>
		<dc:creator>Bhagwat Kumar</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[grails taglib]]></category>
		<category><![CDATA[gsp]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[javascript json]]></category>
		<category><![CDATA[javascript map]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=2627</guid>
		<description><![CDATA[We use internationalization feature in grails using message tag in GSP pages. However arbitrary Groovy/Grails (e.g. tags)  code can not be used in JavaScript as they are not executed on server side. To overcome this I used the following way :
Declare a JSON object in js file or any where else so that this [...]]]></description>
			<content:encoded><![CDATA[<p>We use internationalization feature in grails using message tag in GSP pages. However arbitrary Groovy/Grails (e.g. tags)  code can not be used in JavaScript as they are not executed on server side. To overcome this I used the following way :</p>
<p>Declare a JSON object in js file or any where else so that this object is global one. Create a global JavaScript function that can populate this JSON object. Here is the sample code:</p>
<pre class="brush: jscript;">

var i18nmessages={};

function updateConfigurationMap(newConfigurationMap) {
	for(key in newConfigurationMap){
		i18nmessages[key] = newConfigurationMap[key];
	}
/*
	//or in jQuery way
	jQuery.each(newConfiguration, function(key, val) {
		i18nmessages[key] = val
	});
*/
}
</pre>
<p>Now you can write code like below inside HTML head tag in GSP pages to populate the i18nmessages JSON map:</p>
<pre class="brush: groovy;">

&lt;script type=&quot;text/javascript&quot;&gt;

 updateConfigurationMap({

   noResultError : '${message(code:'project.noResultError'')}.encodeAsHTML()',

   rangeError : '${message(code:'project.rangeError', args:[50, 100]).encodeAsHTML()}',

   ajaxCallUrl : '${createLink(controller:'myController', action: 'myAction')}',

   deleteImagePath : '${resource(dir:'images', file:'myimage.png')}'

 });

&lt;/script&gt;
</pre>
<p>After execution of the above GSP code considering that the JavaScript code written above has executed, you can use messages like this in javascript :</p>
<pre class="brush: jscript;">

function findResult(){
	alert(&quot;Error occurred during processing : &quot;+i18nmessages.noResultError)
}

function getRemoteData(dataToSend){
       /*  note that you can not use createLink grails tag here  */
	jQuery.get(i18nmessages.ajaxCallUrl+&quot;?&quot;+dataToSend, function(response){
		// Process response here.
	})
}

function insertDeleteImage(){
       /* As you can not use resource tag of grails here */
	jQuery('selector').append(&quot;&lt;img src='&quot;+ i18nmessages.deleteImagePath +&quot;' /&gt;&quot;)
}
</pre>
<p>
Obviously there is a drawback with this approach that the JavaScript for setting messages can not be cached in browser. But the advantage is that you are free to use arbitrary Server side code to generate messages. As you have noticed in above code snippet the URL for ajax call and image paths generated using Grails tags can not be used inside the js files.
</p>
<p>
Another idea will be to create separate js files name ending with language suffix(e.g. *-en.js, *-sv.js etc) for each language your app support. Populate the i18nmessages there. Use appropriate js file depending on the request locale(e.g. <code> session.'org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'</code>). This way you can enable caching of js files in browser but you are limited to messages with static content only.
</p>
<p><br/><br />
<em>Please share your ideas how you solved this situation.</em><br />
<br/><br />
Cheers!<br />
~~Bhagwat Kumar~~<br />
bhagwat(at)intelligrape(dot)com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/01/16/grails-taglib-and-javascript-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

