<?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>JQuery &#8211; Jitendra Zaa</title>
	<atom:link href="https://www.jitendrazaa.com/blog/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Tue, 23 Jun 2015 16:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">87744916</site><atom:link rel="search" type="application/opensearchdescription+xml" title="Search Jitendra Zaa" href="https://www.jitendrazaa.com/blog/wp-json/opensearch/1.1/document" />	<item>
		<title>Salesforce REST API Playground</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/salesforce-rest-api-playground/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/salesforce-rest-api-playground/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra Zaa]]></dc:creator>
		<pubDate>Tue, 25 Feb 2014 03:55:21 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[Visualforce]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=3762</guid>

					<description><![CDATA[What is REST API ? In my words, Getting data from Other System or Same System using HTTP request is known as REST API. If you know, how website works, you know REST API. Before REST API, there was SOAP request which needed lots of configuration and very tightly coupled. If you make any modification [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>What is REST API ?</strong></p>
<blockquote><p>In my words, Getting data from Other System or Same System using HTTP request is known as REST API.</p></blockquote>
<p style="text-align: justify;">If you know, how website works, you know REST API. Before REST API, there was <a title="SOAP API" href="https://jitendrazaa.com/blog/java/create-soap-message-using-java/">SOAP </a>request which needed lots of configuration and very tightly coupled. If you make any modification , you had to modify client side also by generating stubs / proxy classes again. There were many more disadvantages which got address by REST API. However, it doesn&#8217;t mean we don&#8217;t need SOAP.</p>
<p style="text-align: justify;">Back to REST API, It is very simple to setup and almost any programming language can make HTTP request so very easy to get data from other source. Return type of REST API can be XML, Simple HTTP, <a title="Why should I use JSON over XML ?" href="https://jitendrazaa.com/blog/salesforce/why-should-i-use-json-over-xml/">JSON </a>or any media like image. However, <a title="Why should I use JSON over XML ?" href="https://jitendrazaa.com/blog/salesforce/why-should-i-use-json-over-xml/">JSON </a>is very popular response type amongst all.</p>
<p>In Past, I have already written one article <a title="Getting record from other Salesforce organization OR communication between multiple salesforce organization" href="https://jitendrazaa.com/blog/salesforce/getting-record-from-one-salesforce-organization-to-other/">demonstrating REST API usage</a>.</p>
<p><strong>How to use Salesforce REST API using <a title="JQuery Tutorials" href="https://jitendrazaa.com/blog/tag/jquery/">JQuery </a>in <a title="Visualforce" href="https://jitendrazaa.com/blog/tag/visualforce/">Visualforce </a>?</strong></p>
<p style="text-align: justify;"><span style="text-decoration: underline;"><strong>REST API Playground</strong></span> : I have created Simple Visualforce page, which demonstrates how to use REST API of Salesforce. It is written in Visualforce with the help of JQuery. You can study this code and play with it in your organization, you just need to copy and paste it.</p>
<p style="text-align: justify;">You also need to add URL &#8220;http://cdnjs.cloudflare.com&#8221; in <em>Remote Site Settings,</em> so that salesforce will allow Visualforce page to get JQuery library from CDN.</p>
<p><span id="more-3762"></span></p>
<p><strong>Video Demo :</strong><br />
<iframe src="//www.youtube.com/embed/zSaSu-JRXWc" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<figure id="attachment_3767" aria-describedby="caption-attachment-3767" style="width: 625px" class="wp-caption alignnone"><a href="https://i0.wp.com/www.jitendrazaa.com/blog/wp-content/uploads/2014/02/REST-API-playground-in-Salesforce.png?ssl=1"><img data-recalc-dims="1" fetchpriority="high" decoding="async" class="size-large wp-image-3767" src="https://i0.wp.com/www.jitendrazaa.com/blog/wp-content/uploads/2014/02/REST-API-playground-in-Salesforce.png?resize=625%2C220&#038;ssl=1" alt="REST API playground in Salesforce" width="625" height="220" srcset="https://i0.wp.com/www.jitendrazaa.com/blog/wp-content/uploads/2014/02/REST-API-playground-in-Salesforce.png?resize=1024%2C362&amp;ssl=1 1024w, https://i0.wp.com/www.jitendrazaa.com/blog/wp-content/uploads/2014/02/REST-API-playground-in-Salesforce.png?resize=300%2C106&amp;ssl=1 300w, https://i0.wp.com/www.jitendrazaa.com/blog/wp-content/uploads/2014/02/REST-API-playground-in-Salesforce.png?resize=624%2C220&amp;ssl=1 624w, https://i0.wp.com/www.jitendrazaa.com/blog/wp-content/uploads/2014/02/REST-API-playground-in-Salesforce.png?w=1321&amp;ssl=1 1321w" sizes="(max-width: 625px) 100vw, 625px" /></a><figcaption id="caption-attachment-3767" class="wp-caption-text">REST API playground in Salesforce</figcaption></figure>
<p><strong>Complete Visualforce page :</strong></p>
<p><script src="https://gist.github.com/JitendraZaa/b9d8d23123b6153f4576.js"></script></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/salesforce-rest-api-playground/feed/</wfw:commentRss>
			<slash:comments>19</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3762</post-id>	</item>
		<item>
		<title>Client side Templating using Underscore.js and JQuery</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/client-side-templating-using-underscore-js-and-jquery/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/client-side-templating-using-underscore-js-and-jquery/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Thu, 02 Jan 2014 02:32:21 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Underscore]]></category>
		<category><![CDATA[Underscore.js]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=3649</guid>

					<description><![CDATA[Recently, I ran into requirement where I was getting JSON response and needed to render it on my Mobile application. I had two Options, Server side processing and Client side Templating. I studied and checked both way ; came to conclusion on using Client side Templating. There are many plugins and libraries available however there [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Recently, I ran into requirement where I was getting <a title="JSON related Articles on Shiva Blog" href="https://jitendrazaa.com/blog/tag/json/">JSON </a>response and needed to render it on my Mobile application. I had two Options, Server side processing and Client side Templating. I studied and checked both way ; came to conclusion on using Client side Templating. There are many plugins and libraries available however there is one which stands different, easy to use and faster as compared to others which is &#8220;<a title="Underscore.js Templating" href="http://documentcloud.github.io/underscore/#template">Underscore.js</a>&#8220;.</p>
<p>Underscore.js library needs JQuery as prerequisite. You can find complete documentation <a title="Undescore.js Documentation" href="http://documentcloud.github.io/underscore/#template">here</a>, Only remember following three points :</p>
<ol>
<li>&lt;% %&gt; &#8211; to execute some code</li>
<li>&lt;%= %&gt; &#8211; to print some value in template</li>
<li>&lt;%- %&gt; &#8211; to print some values with HTML escaped</li>
</ol>
<p><strong>Example Source code:</strong></p>
<p><span id="more-3649"></span>Below Example shows how to render JSON in tabular format using Underscore.js and JQuery.</p>
<pre class="brush: xml; highlight: [42,43,44,45,46,47,48,73]; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;
		Demo of Templating using underscore.js
	&lt;/title&gt;

&lt;style type=&quot;text/css&quot;&gt;
.outer {
    border-collapse: collapse;
    font: 12px/16px arial, sans-serif;
    margin: 20px;
    padding: 0;
	}

.outer td, .outer th {
    border: solid 1px #ddd;
    margin: 0;
    padding: 5px;
}

.outer th, .outer div.th {
    background: #EEE;
    font-weight: bold;
}
&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;table class=&quot;outer&quot;&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Sr. No&lt;/th&gt;
            &lt;th&gt;Name&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
    &lt;/tbody&gt;
&lt;/table&gt;

&lt;script type=&quot;text/html&quot; id='table-data'&gt;
    &lt;% _.each(items,function(item,key,list){ %&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;%= key+1 %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= item.name %&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;% }) %&gt;

&lt;/script&gt;

	&lt;script type=&quot;text/JavaScript&quot;

src=&quot;http://code.jquery.com/jquery-1.10.2.min.js&quot;

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

src=&quot;http://underscorejs.org/underscore-min.js&quot; &gt;&lt;/script&gt;

	&lt;script type=&quot;text/JavaScript&quot; &gt;
	var items = &#x5B;
		{name:&quot;Shivasoft&quot;},
		{name:&quot;Salesforce&quot;},
		{name:&quot;JQuery&quot;},
		{name:&quot;UnderscoreJS&quot;},
		{name:&quot;Template&quot;},
		{name:&quot;Client Side Templating&quot;}
	]

	var tableTemplate = $(&quot;#table-data&quot;).html();

	$(&quot;table.outer tbody&quot;).html(_.template( tableTemplate,{items:items} ));

	&lt;/script&gt;

&lt;/body&gt;

&lt;/html&gt;
</pre>
<p><strong>Output:</strong></p>
<figure id="attachment_3651" aria-describedby="caption-attachment-3651" style="width: 210px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2014/01/Underscore-js.png?ssl=1"><img data-recalc-dims="1" decoding="async" class="size-full wp-image-3651" alt="Underscore.js" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2014/01/Underscore-js.png?resize=210%2C219&#038;ssl=1" width="210" height="219" /></a><figcaption id="caption-attachment-3651" class="wp-caption-text">Underscore.js</figcaption></figure>
<p><strong>How it Works ?</strong></p>
<ol>
<li>Line 31, we are going to append data in this table.</li>
<li>Line 42-48, defines template on how we are going to render JSON values. We are looping through values and rendering in &#8220;td&#8221; tag of &#8220;table&#8221;.</li>
<li>Line 73, Single line is doing the magic here. It is getting template which is defined between line 42 and 48 and then rendering values in table defined at line 31.</li>
</ol>
<p>Please leave comment for feedback.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/client-side-templating-using-underscore-js-and-jquery/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3649</post-id>	</item>
		<item>
		<title>JQuery Based Raffle in Salesforce</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/jquery-based-raffle-in-salesforce/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/jquery-based-raffle-in-salesforce/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Fri, 28 Jun 2013 21:19:02 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Raffle]]></category>
		<category><![CDATA[Visualforce]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=3355</guid>

					<description><![CDATA[Recently i run into very interesting scenario where i had to randomly take name of few contacts. There are many ways to do it but I thought why not to implement this functionality in Salesforce with help of some Javascript? So i came up with this &#8211; JQuery based Raffle in Salesforce. I have created [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Recently i run into very interesting scenario where i had to randomly take name of few contacts. There are many ways to do it but I thought why not to implement this functionality in Salesforce with help of some Javascript? So i came up with this &#8211;<strong> JQuery based Raffle in Salesforce</strong>.</p>
<p>I have created a List View Button, where I select few contacts and using JQuery, One Contact is selected Randomly. Assuming that you already know how to create List View Button, I will share my Visualforce and Controller Extension code with you.</p>
<p>Also, Please note that to run this demo, you need to have JQuery file in your static resource with name &#8220;JQueryAndCss&#8221;.<br />
<span id="more-3355"></span></p>
<figure id="attachment_3357" aria-describedby="caption-attachment-3357" style="width: 532px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2013/06/JQuery-Based-Raffle-in-Salesforce.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class=" wp-image-3357  " alt="JQuery Based Raffle in Salesforce" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2013/06/JQuery-Based-Raffle-in-Salesforce.png?resize=532%2C217&#038;ssl=1" width="532" height="217" /></a><figcaption id="caption-attachment-3357" class="wp-caption-text">JQuery Based Raffle in Salesforce</figcaption></figure>
<p><span style="text-decoration: underline;"><strong>Visualforce &#8211; PlayRaffle</strong></span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;apex:page standardController=&quot;sfdc_contact__c&quot; recordSetVar=&quot;contacts&quot; extensions=&quot;PlayRaffle&quot;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;{!URLFOR($Resource.JQueryAndCss, 'jquery_1.7.1.min.js')}&quot;&gt; &lt;/script&gt;

&lt;style type=&quot;text/css&quot;&gt;

        ol.raffleComponent {
            list-style-type: none ;
            float: left ;
            font-size: 20px ;
            margin: 0px 0px 0px 0px ;
            padding: 0px 0px 0px 0px ;
            }

        ol.raffleComponent li, .winnerDiv {
            background-color: #FAFAFA ;
            border: 2px solid #454545 ;
            float: left ;
            line-height: 60px ;
            margin: 0px 10px 10px 0px ;
            overflow: hidden ;
            padding: 0px 10px 0px 10px ;
            text-align: center ;
            }

        ol.raffleComponent li.on , .winnerDiv{
            background-color: gold ;
            }

        .winnerDiv{
            display : none;
            font-size: 30px ;
            }

    &lt;/style&gt;

    &lt;button type=&quot;submit&quot; OnClick=&quot;RunRaffle()&quot;&gt;Run Raffle&lt;/button&gt;
    &lt;br /&gt;

    &lt;ol class=&quot;raffleComponent&quot;&gt;
         &lt;apex:repeat value=&quot;{!contactNames }&quot; var=&quot;conName&quot;&gt;
            &lt;li&gt;&lt;div&gt; {!conName} &lt;/div&gt;&lt;/li&gt;
         &lt;/apex:repeat&gt;
    &lt;/ol&gt;

        &lt;br clear=&quot;all&quot; /&gt;
    &lt;br /&gt;

    &lt;div class=&quot;winnerDiv&quot; &gt;&lt;/div&gt;
    &lt;br clear=&quot;all&quot; /&gt;

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

        // Initializes and runs the raffle.
        function RunRaffle(  ){
            var jRaffle = $( &quot;.raffleComponent&quot; );

            // Clear the raffle list.
            //jRaffle.empty();
            $(&quot;.winnerDiv&quot;).hide();

            // Find the &quot;on&quot; element.
            var jCurrentLI = jRaffle.find( &quot;li:first&quot; ).addClass( &quot;on&quot; );

            // Get base pause time.
            var intPause = 40;

            // Get the time to wait before chaning the pause time.
            var intDelay = (4500 + (Math.random() * 2000));

            // Define the ticker.
            var Ticker = function(){

                var jNextLI = jCurrentLI.next( &quot;li&quot; );

                // Check to see if there is a next LI.
                if (!jNextLI.length){

                    // Since there is no LI left in the list, our next LI will be the
                    // first one in the list.
                    jNextLI = jRaffle.find( &quot;li:first&quot; );

                }

                // Turn off the current list.
                jCurrentLI.removeClass( &quot;on&quot; );

                // Turn on next list.
                jNextLI.addClass( &quot;on&quot; );

                // Store the new LI in the current LI (for next iteration).
                jCurrentLI = jNextLI;

                // Check to see if we should start changing the pause duration.
                if (intDelay &gt; 0){

                    // Substract from the delay.
                    intDelay -= intPause;

                } else {

                    // Change the pause.
                    intPause *= (1 + (Math.random() * .1));

                }

                // Check to see how long the pause it. Once it gets over a certain wait
                // time, we are done playing and picking the winner.
                if (intPause &gt;= 400){

                    // We found a winner!
                    var resulDiv = $(&quot;.winnerDiv&quot;);
                    resulDiv.html(&quot;Winner is - &quot;+ jCurrentLI.text() + ' !!!');
                    resulDiv.addClass(&quot;on&quot;);
                    resulDiv.show();

                } else {

                    // Not done yet, call again shortly.
                    setTimeout( Ticker, intPause );

                }
            }

            // Start ticker.
            Ticker();
        }
    &lt;/script&gt;

&lt;/apex:page&gt;
</pre>
<p><span style="text-decoration: underline;"><strong>Controller Extension : PlayRaffle</strong></span></p>
<pre class="brush: java; title: ; notranslate">
public class PlayRaffle {

    public List&lt;String&gt; contactNames {get;set;}

    public PlayRaffle(ApexPages.StandardSetController controller) {

        contactNames = new List&lt;String&gt;();
        List&lt;SFDC_Contact__c&gt; sfdcContacts = (List&lt;SFDC_Contact__c&gt;)controller.getSelected();
        Set&lt;Id&gt; conIds = new Set&lt;Id&gt;();
         for(SFDC_Contact__c s : sfdcContacts )
        {
            conIds.add(s.Id);
        }

        sfdcContacts = &#x5B;Select Name, Last_Name__c FROM SFDC_Contact__c Where Id IN : conIds];

        for(SFDC_Contact__c s : sfdcContacts )
        {
            contactNames.add(s.Name+' '+s.Last_Name__c);
        }

    }

}
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/jquery-based-raffle-in-salesforce/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3355</post-id>	</item>
		<item>
		<title>AutoComplete Component in Visualforce using JQueryUI</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/ajax-based-autocomplete-component-in-salesforce-using-jquery-ui-and-json/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/ajax-based-autocomplete-component-in-salesforce-using-jquery-ui-and-json/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Fri, 28 Jun 2013 18:23:42 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[Autocomplete]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JQuery UI]]></category>
		<category><![CDATA[JSON]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=3347</guid>

					<description><![CDATA[In this tutorial, I am going to explain very Simple AJAX and JSON based Auto Complete component with the help of JQuery UI. First I am assuming that you already have Static Resource of named &#8220;AutoCompleteWithModal&#8220;. This Static resource has all images, CSS and JQuery library needed to implement this component. In one of my [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this tutorial, I am going to explain very Simple AJAX and JSON based Auto Complete component with the help of <a title="jQuery UI" href="http://jqueryui.com/" target="_blank" rel="nofollow">JQuery UI</a>. First I am assuming that you already have Static Resource of named &#8220;<a title="Salesforce Static Resource" href="https://jitendrazaa.com/blog/wp-content/uploads/2013/06/AutoCompleteWithModal.zip" target="_blank">AutoCompleteWithModal</a>&#8220;. This Static resource has all images, CSS and JQuery library needed to implement this component.</p>
<p>In <a title="JSON Output in Visualforce" href="https://jitendrazaa.com/blog/salesforce/json-output-in-visualforce/" target="_blank">one of my old post</a>, I have already explained that how to generate JSON in Visualforce page. So Considering same article I have create Visualforce page named &#8220;Account_JSON&#8221; which returns list of Accounts on basis of text entered in input field.<span id="more-3347"></span></p>
<p><strong>Live Demo :</strong></p>
<p>try searching &#8220;gen&#8221; or &#8220;edg&#8221; and spacebar, It will load account after one space.</p>
<p><iframe loading="lazy" src="http://shivasoft-developer-edition.ap1.force.com/Exp/AutoCompleteDemo" height="100" width="100%" frameborder="0" scrolling="no"></iframe></p>
<p><strong>Visualforce Account_JSON :</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;apex:page Controller=&quot;AccountJSONCreator&quot; contentType=&quot;application/x-JavaScript; charset=utf-8&quot; showHeader=&quot;false&quot; standardStylesheets=&quot;false&quot; sidebar=&quot;false&quot;&gt;
{!JSON}
&lt;/apex:page&gt;
</pre>
<p><strong>Controller AccountJSONCreator :</strong></p>
<pre class="brush: java; title: ; notranslate">
public with sharing class AccountJSONCreator {

    public String getJSON()
    {
        String AccountName = Apexpages.currentPage().getParameters().get('AccName');
        List&lt;AccountWrapper&gt; wrp = new List&lt;AccountWrapper&gt;();
        for (Account a : &#x5B;Select a.Id, a.Website, a.Name, a.BillingCountry, a.BillingCity
                            From
                                Account a
                            WHERE Name Like : '%'+AccountName+'%' ]) {
               AccountWrapper w = new AccountWrapper (a.Name, nullToBlank (a.BillingCountry), nullToBlank (a.BillingCity));
               wrp.add(w);
            }
        return JSON.serialize(wrp);
    }

    public String nullToBlank(String val)
    {
        return val == null ?'':val;
    }

    public class AccountWrapper
    {
        String AccName,BillingCountry,BillingCity;

        public AccountWrapper(String aName, String bCountry, String bCity)
        {
            AccName = aName;
            BillingCountry = bCountry;
            BillingCity = bCity;
        }
    }

    static testMethod void AccountJSONCreatorTest() {
        AccountJSONCreator obj = new AccountJSONCreator();
        obj.getJSON();
    }
}
</pre>
<p>Now let&#8217;s create a Component which will make AJAX request to above visualforce page &#8220;Account_JSON&#8221; and Parse JSON page using JQuery.</p>
<p><strong>Component Autocomplete_Component :</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;apex:component&gt;
 &lt;apex:attribute name=&quot;ComponentLabel&quot; description=&quot;Label of Component&quot;
                    type=&quot;String&quot; required=&quot;true&quot;/&gt;

&lt;apex:stylesheet value=&quot;{!URLFOR($Resource.AutoCompleteWithModal, '/JQueryUI/css/ui-lightness/jquery-ui-1.8.17.custom.css')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.AutoCompleteWithModal, '/JQueryUI/js/jquery-1.7.1.min.js')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.AutoCompleteWithModal, '/JQueryUI/js/jquery-ui-1.8.17.custom.min.js')}&quot;/&gt;
&lt;apex:stylesheet value=&quot;{!URLFOR($Resource.AutoCompleteWithModal, '/JQueryModal/css/basic.css')}&quot;/&gt;

&lt;style type=&quot;text/css&quot;&gt;
    .ui-autocomplete-loading { background: white url('{!URLFOR($Resource.AutoCompleteWithModal, 'AjaxLoad.gif')}') right center no-repeat; }
&lt;/style&gt;

{!ComponentLabel} &lt;apex:inputText id=&quot;theTextInput&quot;/&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
//$ac - AutoComplete

$ac = jQuery.noConflict();

function getLoadingImage()
{
    var loadImagURL = &quot;{!URLFOR($Resource.AutoCompleteWithModal, 'BigLoad.gif')}&quot;;
    var retStr = &#x5B;'&lt;img src=&quot;', loadImagURL ,'&quot; title=&quot;loading...&quot; alt=&quot;loading...&quot; class=&quot;middleAlign&quot; /&gt;'];
    return retStr.join(&quot;&quot;);
}

var sourcePage = 'https://c.ap1.visual.force.com/apex/Account_JSON?core.apexpages.devmode.url=0';

 $ac(function() {
        var txtVal =  $ac('&#x5B;id=&quot;{!$Component.theTextInput}&quot;]');
        //This method returns the last character of String
        function extractLast(term) {
            return term.substr(term.length - 1);
        }

        $ac('&#x5B;id=&quot;{!$Component.theTextInput}&quot;]').autocomplete({
            source: function( request, response ) {

                //Abort Ajax
                var $this = $ac(this);
                var $element = $ac(this.element);
                var jqXHR = $element.data('jqXHR');
                if(jqXHR)
                    jqXHR.abort();

                $ac('&#x5B;id=&quot;{!$Component.theTextInput}&quot;]').addClass('ui-autocomplete-loading');
                //prompt('',sourcePage+'&amp;key='+txtVal.val());
                $element.data('jqXHR',$ac.ajax({
                    url: sourcePage+'&amp;AccName='+txtVal.val(),
                    dataType: &quot;json&quot;,
                    data: {
                    },
                    success: function( data ) {
                        response( $ac.map( data , function( item ) {
                            return {
                                label: '&lt;a&gt;'+
                                item.AccName+&quot;&lt;br /&gt;&quot;+
                                '&lt;span style=&quot;font-size:0.8em;font-style:italic&quot;&gt;'
                                +item.BillingCity+', '+item.BillingCountry+
                                &quot;&lt;/span&gt;&lt;/a&gt;&quot;,
                                value: item.AccName
                            }
                        }));
                    },
                    complete: function() {

                        //This method is called either request completed or not
                        $this.removeData('jqXHR');

                        //remove the class responsible for loading image
                        $ac('&#x5B;id=&quot;{!$Component.theTextInput}&quot;]').removeClass('ui-autocomplete-loading');
                    }
                })
                );

            },
            search: function() {
                /*
                // If last character is space
                    var term = extractLast(this.value);
                    if(term == &quot; &quot;)
                    {
                        return true;
                    }
                */

                //If String contains at least 1 space
                if (this.value.indexOf(&quot; &quot;) &gt;= 0)
                {
                    $ac('&#x5B;id=&quot;{!$Component.theTextInput}&quot;]').autocomplete('option', 'delay', 500);
                    return true;
                }
                return false;
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function(event, ui) {
                var selectedObj = ui.item;
                //alert(selectedObj.compId);
                //getCompanyDetail(selectedObj.compId);
                return true;
            }
        }).data(&quot;autocomplete&quot;)._renderItem = autoCompleteRender;

    });

function autoCompleteRender(ul, item) {
    return $ac(&quot;&lt;li&gt;&lt;/li&gt;&quot;).data(&quot;item.autocomplete&quot;, item).append(item.label).appendTo(ul);
}

&lt;/script&gt;
&lt;/apex:component&gt;
</pre>
<p>Now Visualforce page, which will host above Component.</p>
<p><strong>Viusalforce Page : AutoCompleteDemo</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;apex:page &gt;
    &lt;apex:form &gt;
        &lt;c:autocomplete_component ComponentLabel=&quot;Enter Account Name : &quot;/&gt;
    &lt;/apex:form&gt;
&lt;/apex:page&gt;
</pre>
<figure id="attachment_3350" aria-describedby="caption-attachment-3350" style="width: 599px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2013/06/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="size-full wp-image-3350" alt="JQuery UI and JSON based AJAX AutoComplete Component in Salesforce" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2013/06/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=599%2C407&#038;ssl=1" width="599" height="407" /></a><figcaption id="caption-attachment-3350" class="wp-caption-text">JQuery UI and JSON based AJAX AutoComplete Component in Salesforce</figcaption></figure>
<p>Download Static resource &#8211; <a href="https://www.jitendrazaa.com/blog/wp-content/uploads/2013/06/AutoCompleteWithModal1.zip">AutoCompleteWithModal</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/ajax-based-autocomplete-component-in-salesforce-using-jquery-ui-and-json/feed/</wfw:commentRss>
			<slash:comments>19</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3347</post-id>	</item>
		<item>
		<title>Salesforce Helptext like Custom Tooltip using JQuery</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/salesforce-helptext-like-custom-tooltip-using-jquery/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/salesforce-helptext-like-custom-tooltip-using-jquery/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Mon, 04 Feb 2013 01:24:50 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Visual]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=3134</guid>

					<description><![CDATA[Welcome back Readers. This is my first blog entry for year 2013, i know its too late. However i can ensure that i have lots of unique post which will come this year. I am starting this year with very light post , mimic the help-text style of Salesforce. Download Salesforce Helptext like Tooltip using [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Welcome back Readers. This is my first blog entry for year 2013, i know its too late. However i can ensure that i have lots of unique post which will come this year. I am starting this year with very light post , mimic the help-text style of Salesforce.</p>
<figure id="attachment_3179" aria-describedby="caption-attachment-3179" style="width: 304px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2013/02/Salesforce-like-Tooltip-using-JQuery.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="size-full wp-image-3179" alt="Salesforce like Helptext - Tooltip using JQuery" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2013/02/Salesforce-like-Tooltip-using-JQuery.png?resize=304%2C102&#038;ssl=1" width="304" height="102" /></a><figcaption id="caption-attachment-3179" class="wp-caption-text">Salesforce like Helptext &#8211; Tooltip using JQuery</figcaption></figure>
<p><a href="https://jitendrazaa.com/blog/wp-content/uploads/2013/02/Tooltip.zip">Download Salesforce Helptext like Tooltip using JQuery &#8211; Source Code</a></p>
<p>Most of the time when i override Visualforce page, customers many time demand for same Standard page layout.</p>
<p>apex:inputField and apex:outputField shows their help bubble (if applicable) when nested within a pageBlockSection component automatically.</p>
<p>If you want to provide your own text instead you can by utilizing the helpText attribute on pageBlockSectionItem. Also you can access the help text within an expression by using the respective $ObjectType global as such:<span id="more-3134"></span></p>
<pre class="brush: xml; title: ; notranslate">
$ObjectType.Account.Fields.myField__c.inlineHelpText
</pre>
<p>However, there are scenario when we cant use pageBlockSection component. So, i came up with my own helptext CSS and javascript. For this post i am using <a title="jQuery Documentation" href="http://jquery.com/" rel="nofollow">JQuery </a>and <a title="JQuery Tooltip Plugin" href="http://bassistance.de/jquery-plugins/" rel="nofollow">JQuery tooltip plugin</a>.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
&lt;title&gt;Salesforce Helptext like Custom Tooltip using JQuery&lt;/title&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;jquery.tooltip.css&quot; /&gt;
&lt;script src=&quot;http://code.jquery.com/jquery-1.8.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://jquery.bassistance.de/tooltip/jquery.tooltip.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
$Jtool = jQuery.noConflict();

$Jtool(
	function() {
		$spnEle = $Jtool('.spnCustomTooltip');
		$spnEle.find('img').tooltip({showURL: false});
		$spnEle.mouseover(function() {
			$Jtool(this).find('img').addClass('helpButtonOn_cust');
		});
		$spnEle.mouseleave(function() {
		  $Jtool(this).find('img').removeClass('helpButtonOn_cust');
		});
	}
);

&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div id=&quot;main&quot;&gt;
Sample
&lt;span class=&quot;spnCustomTooltip&quot;&gt;
		&lt;img src=&quot;s.gif&quot; class=&quot;helpButton_cust&quot; title='This is Sample Custom Tooltip / Helptext like Standard Salesforce Help Text'&gt;
		&lt;/span&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><a href="https://jitendrazaa.com/blog/wp-content/uploads/2013/02/Tooltip.zip">Download Salesforce Helptext like Tooltip using JQuery &#8211; Source Code</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/salesforce-helptext-like-custom-tooltip-using-jquery/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3134</post-id>	</item>
		<item>
		<title>Change year range in Datepicker &#8211; Salesforce</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/change-year-range-in-datepicker-salesforce/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/change-year-range-in-datepicker-salesforce/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Thu, 20 Sep 2012 12:52:49 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[Home page Component]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=3106</guid>

					<description><![CDATA[In Datepicker control of salesforce, most of the developers must have faced issue on year range for Datepicker control. We cannot configure the year range in standard date picker control. However, for a long time i am using a JQuery code to change the range of years in Datepicker and thought to share with you. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">In Datepicker control of salesforce, most of the developers must have faced issue on year range for Datepicker control. We cannot configure the year range in standard date picker control. However, for a long time i am using a JQuery code to change the range of years in Datepicker and thought to share with you. You can find similar solution at many places but thought to add in my articles library also.</p>
<figure id="attachment_3107" aria-describedby="caption-attachment-3107" style="width: 225px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/09/Year-Range-in-Salesforce-Date-Picker.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="size-full wp-image-3107" title="Year Range in Salesforce Date Picker" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/09/Year-Range-in-Salesforce-Date-Picker.png?resize=225%2C184&#038;ssl=1" alt="Year Range in Salesforce Date Picker" width="225" height="184" /></a><figcaption id="caption-attachment-3107" class="wp-caption-text">Year Range in Salesforce Date Picker</figcaption></figure>
<p style="text-align: justify;">So, lets start to resolve this problem. The only thing we will need is Javascript based Home page Component.<br />
Navigate to <strong>&#8220;Set up | App SetUp | Customize | Home | Home Page Components&#8221;</strong>.<br />
click on &#8220;New&#8221; Custom Component. In Next screen you will prompted with the type of Homepage component.<span id="more-3106"></span></p>
<figure id="attachment_3108" aria-describedby="caption-attachment-3108" style="width: 593px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/09/Homepage-Component-Type-in-Salesforce.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="size-full wp-image-3108" title="Homepage Component Type in Salesforce" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/09/Homepage-Component-Type-in-Salesforce.png?resize=593%2C307&#038;ssl=1" alt="Homepage Component Type in Salesforce" width="593" height="307" /></a><figcaption id="caption-attachment-3108" class="wp-caption-text">Homepage Component Type in Salesforce</figcaption></figure>
<p>Select &#8220;HTML Area&#8221;.<br />
In Next screen, click on checkbox &#8220;Show HTML&#8221; as shown in below image.</p>
<figure id="attachment_3109" aria-describedby="caption-attachment-3109" style="width: 440px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/09/Javascript-code-in-Home-Page-component-Salesforce.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="size-full wp-image-3109" title="Javascript code in Home Page component - Salesforce" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/09/Javascript-code-in-Home-Page-component-Salesforce.png?resize=440%2C389&#038;ssl=1" alt="Javascript code in Home Page component - Salesforce" width="440" height="389" /></a><figcaption id="caption-attachment-3109" class="wp-caption-text">Javascript code in Home Page component &#8211; Salesforce</figcaption></figure>
<p>Now write below Javascript code in HTML area :</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;span id=&quot;hideThisHomePageComp&quot;&gt;&lt;/span&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$j = jQuery.noConflict();
$j(document).ready(function() {
                var startYear=1985;
                var endYear=2024;
                var htmlStr='';
                if(startYear&lt;endYear){
                                for(i=startYear;i&lt;endYear+1;i++){
                                                htmlStr += &quot;&lt;option value=&quot;&quot;+i+&quot;&quot;&gt;&quot;+i+&quot;&lt;/option&gt;&quot;;
                                }
                                $j('#calYearPicker').html(htmlStr);
                }
                $j('#sidebarDiv #hideThisHomePageComp').parent().parent().hide();
                }
);
&lt;/script&gt;
</pre>
<p><span style="text-decoration: underline;"><strong>Note:</strong></span></p>
<ul>
<li>While importing JQuery from Google or any other CDN, don&#8217;t write &#8220;http&#8221; protocol. It will automatically detect the protocol.</li>
<li>Don&#8217;t write any single line comment, as Salesforce will internally convert above Javascript code into single line. And if you write any single line comment then everything after that will be commented. Multiple line comment will work.</li>
<li>If you are using Datepicker in custom Visualforce page and if sidebar is not enabled then above work around will not work.</li>
<li>We are hiding the home page component itself by line &#8220;parent().parent().hide()&#8221;, as there is no need to show this component to end user.</li>
</ul>
<p><strong>Update &#8211; 23-Jul-2015</strong></p>
<p style="text-align: justify;">Above solution will not work after Summer 15 as HTML area is changed not to allow javascript, However you can check<a href="http://salesforce.stackexchange.com/questions/38918/end-of-javascript-sidebar-workarounds"> this SFSE thread</a> for still workable workaround to inject above Javacsript.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/change-year-range-in-datepicker-salesforce/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3106</post-id>	</item>
		<item>
		<title>Streaming API Using JQuery &#8211; Salesforce</title>
		<link>https://www.jitendrazaa.com/blog/others/tips/streaming-api-using-jquery-salesforce/</link>
					<comments>https://www.jitendrazaa.com/blog/others/tips/streaming-api-using-jquery-salesforce/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Sun, 06 May 2012 11:40:48 +0000</pubDate>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Salesforce]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=2843</guid>

					<description><![CDATA[Tutorial of Streaming API in Salesforce with Source code and Demo Video - Implementation of Bayeux protocol and CometD using JQuery and JSON]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Push technology is a model of Internet-based communication in which information transfer is initiated <strong>from a server to the client</strong>. Also called the publish/subscribe model, this type of communication is the opposite of pull technology in which a request for information is made from a client to the server. The information that&#8217;s sent by the server is typically specified in advance. When using Streaming API, you specify the information the client receives by creating a PushTopic. The client then subscribes to the PushTopic channel to be notified of events that match the PushTopic criteria.</p>
<p style="text-align: justify;">In push technology, the server pushes out information to the client after the client has subscribed to a channel of information. In order for the client to receive the information, the client must maintain a connection to the server. <strong>Streaming API uses the Bayeux protocol and <a title="Wikipedia Tutorial" href="http://en.wikipedia.org/wiki/Comet_(programming)" rel="nofollow">CometD</a></strong>, so the client to server connection is maintained through long polling.</p>
<p>The Bayeux protocol and CometD both use long polling.</p>
<ol>
<li>Bayeux is a protocol for transporting asynchronous messages, primarily over HTTP.</li>
<li>CometD is a scalable HTTP-based event routing bus that<strong> uses an AJAX push technology pattern known as Comet</strong>. It implements the Bayeux protocol.</li>
</ol>
<p>There is nice jQuery plugin available on web which implements Bayeux protocol and CometD.</p>
<p><a title="Streaming API Documentation" href="http://www.salesforce.com/us/developer/docs/api_streaming/index_Left.htm#StartTopic=Content/code_sample_java_add_source.htm">Navigate here for Salesforce documentation for Streaming API.</a></p>
<p><strong>Common Terms used in Streaming API:</strong></p>
<ul>
<li><strong>Event :</strong> Either the creation of a record or the update of a record. Each event may trigger a notification.</li>
<li><strong>Notification :</strong> A message in response to an event. The notification is sent to a channel to which one or more clients are subscribed.</li>
<li><strong>PushTopic :</strong> A record that you create. The essential element of a PushTopic is the SOQL query. The PushTopic defines a Streaming API channel.</li>
</ul>
<p><strong>Example used in this article : </strong></p>
<p><strong></strong>I want notifications about all opportunity whose status is won.<br />
<em>First step to implement any streaming API is to create the Push Topic, which is going to subscribed by all the clients.</em><br />
<strong></strong></p>
<p><strong>Create PushTopic:</strong></p>
<p>To create PushTopic, we will need the developer console of the Salesforce and assume that the name of the topic is &#8220;WonOpportunity&#8221;.</p>
<pre class="brush: csharp; title: ; notranslate">
PushTopic pushTopic = new PushTopic();
pushTopic.ApiVersion = 23.0;
pushTopic.Name = 'WonOpportunity';
pushTopic.Description = 'Notify if the Opportunity won';
pushTopic.NotifyForOperations = 'All';
pushTopic.NotifyForFields = 'Referenced';
pushtopic.Query = 'Select o.OwnerId, o.Name, o.IsWon, o.Id, o.Amount From Opportunity o WHERE o.IsWon = true';
insert pushTopic;
System.debug('Created new PushTopic: '+ pushTopic.Id);
</pre>
<figure id="attachment_2845" aria-describedby="caption-attachment-2845" style="width: 645px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Salesforce-Streaming-API-Create-Push-topic.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class=" wp-image-2845  " title="Salesforce Streaming API - Create Push topic" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Salesforce-Streaming-API-Create-Push-topic-1024x332.png?resize=645%2C209&#038;ssl=1" alt="Salesforce Streaming API - Create Push topic" width="645" height="209" /></a><figcaption id="caption-attachment-2845" class="wp-caption-text">Salesforce Streaming API - Create Push topic</figcaption></figure>
<p><strong><span id="more-2843"></span>Step 2:</strong><br />
Download the CometD compressed archive (.tgz) file from<a title="cometd implementation" href="http://download.cometd.org/cometd-2.2.0-distribution.tar.gz" rel="nofollow"> http://download.cometd.org/cometd-2.2.0-distribution.tar.gz</a><br />
<strong></strong></p>
<p><strong>Step 3:</strong><br />
In the extracted folder you will find the war file at location &#8220;cometd-2.2.0/cometd-javascript/common/target&#8221;.</p>
<p>Unpack that war file using below DOS command in Windows and same command will work on shell also</p>
<pre class="brush: powershell; title: ; notranslate">
cd cometd-2.2.0/cometd-javascript/common/target
jar xvf cometd-javascript-common-2.2.0.war org/cometd.js
</pre>
<figure id="attachment_2846" aria-describedby="caption-attachment-2846" style="width: 627px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Salesforce-UnPack-war-file-Streaming-API.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="size-full wp-image-2846" title="Salesforce UnPack war file - Streaming API" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Salesforce-UnPack-war-file-Streaming-API.png?resize=627%2C150&#038;ssl=1" alt="Salesforce UnPack war file - Streaming API" width="627" height="150" /></a><figcaption id="caption-attachment-2846" class="wp-caption-text">Salesforce UnPack war file - Streaming API</figcaption></figure>
<p>If you will not follow the above step and if use different &#8220;cometd.js&#8221; file then you may get error <strong>&#8220;Uncaught ReferenceError: org is not defined&#8221;</strong><br />
<strong></strong></p>
<p><strong>Step 4:</strong><br />
Extract the following JavaScript files from &#8220;<em>cometd-2.2.0-distribution.tar.gz</em>&#8221;</p>
<ul>
<li>cometd-2.2.0/cometd-javascript/common/target/org/cometd.js <em>(This file must be from war file)</em></li>
<li>cometd-2.2.0/cometd-javascript/jquery/src/main/webapp/jquery/jquery-1.5.1.js</li>
<li>cometd-2.2.0/cometd-javascript/jquery/src/main/webapp/jquery/json2.js</li>
<li>cometd-2.2.0/cometd-javascript/jquery/src/main/webapp/jquery/jquery.cometd.js</li>
</ul>
<p><strong>Step 5:</strong><br />
Create a Visualforce page with following code :</p>
<pre class="brush: xml; title: ; notranslate">
&lt;apex:page &gt;

&lt;apex:includeScript value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/JQueryComet/Cometd.js')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/jquery_1.5.2.min.js')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/JQueryComet/json2.js')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/JQueryComet/jquery.cometd.js')}&quot;/&gt;

&lt;apex:includeScript value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/Style/jquery-animate-css-rotate-scale.js')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/Style/jquery-css-transform.js')}&quot;/&gt;

&lt;apex:stylesheet value=&quot;{!URLFOR($Resource.SteamingAPI, 'StreaminAPI/Style/style.css')}&quot;/&gt;

&lt;div class=&quot;menu&quot;&gt;
&lt;!-- Place holder for notifications --&gt;
&lt;/div&gt;

	 &lt;script type=&quot;text/javascript&quot;&gt;
	    var $jq = jQuery.noConflict();

            $jq('.item').click(
                function(){
                    var $this = $jq(this);
                    expand($this);
                }
            );
            function expand($elem){
                var angle = 0;
                var t = setInterval(function () {
                    if(angle == 1440){
                        clearInterval(t);
                        return;
                    }
                    angle += 40;
                    $jq('.link',$elem).stop().animate({rotate: '+=-40deg'}, 0);
                },10);
                $elem.stop().animate({width:'500px'}, 1000)
                .find('.item_content').fadeIn(400);
            }

           function createEle(data)
           {
	           	var $itemDiv = $jq(document.createElement('div'));
	           	$itemDiv.addClass('item');

	           	var $anch =  $jq(document.createElement('a'));
	           	$anch.addClass('link');
	           	$anch.addClass('icon_alert');

	           	var $contentDiv = $jq(document.createElement('div'));
	           	$contentDiv.addClass('item_content');

	           	var $h2 = $jq(document.createElement('h2'));
	           	$h2.html('Won New Opportunity');
	           	$contentDiv.append($h2);

	           	$contentDiv.append('&lt;br /&gt;Name : '+data.Name+' &lt;br /&gt;	Amount : '+data.Amount+' &lt;br /&gt;&lt;a href=&quot;#&quot;&gt; Navigate to Opportunity &lt;/a&gt;');

	           	$itemDiv.append($anch);
	           	$itemDiv.append($contentDiv);
	           	$jq(&quot;.menu&quot;).append($itemDiv);
	           	expand($itemDiv);
           }

           $jq(function() {
			 	 // Connect to the CometD endpoint

	            $jq.cometd.init({
	               url: window.location.protocol+'//'+window.location.hostname+'/cometd/23.0/',
	               requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
	           });

	          $jq.cometd.subscribe('/topic/WonOpportunity', function(message) {
	          		createEle(message.data.sobject);
	            });

			});

        &lt;/script&gt;
&lt;/apex:page&gt;
</pre>
<p>After saving this page, open same salesforce instance in other browser or tab and make change to any opportunity with status &#8220;won&#8221;, it will display an alert that opportunity is won.<br />
<strong>Output:</strong></p>
<figure id="attachment_2847" aria-describedby="caption-attachment-2847" style="width: 543px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Salesforce-Streaming-API-Example.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class=" wp-image-2847 " title="Salesforce Streaming API Example" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Salesforce-Streaming-API-Example.png?resize=543%2C340&#038;ssl=1" alt="Salesforce Streaming API Example" width="543" height="340" /></a><figcaption id="caption-attachment-2847" class="wp-caption-text">Salesforce Streaming API Example</figcaption></figure>
<p><strong>JSON Reponse:</strong><br />
following JSON response we gets from Streaming API. The Rows returned in Object depends upon the Push topic create earlier.</p>
<pre class="brush: xml; title: ; notranslate">
&#x5B;
   {
      &quot;channel&quot;:&quot;/topic/WonOpportunity&quot;,
      &quot;data&quot;:{
         &quot;event&quot;:{
            &quot;type&quot;:&quot;created&quot;,
            &quot;createdDate&quot;:&quot;2012-05-05T10:06:45.000+0000&quot;
         },
         &quot;sobject&quot;:{
            &quot;Name&quot;:&quot;om&quot;,
            &quot;IsWon&quot;:true,
            &quot;Amount&quot;:null,
            &quot;OwnerId&quot;:&quot;00590000000Gl5VAAS&quot;,
            &quot;Id&quot;:&quot;00690000006C8yFAAS&quot;
         }
      }
   },
   {
      &quot;channel&quot;:&quot;/meta/connect&quot;,
      &quot;advice&quot;:{
         &quot;reconnect&quot;:&quot;retry&quot;,
         &quot;interval&quot;:0,
         &quot;timeout&quot;:110000
      },
      &quot;successful&quot;:true,
      &quot;id&quot;:&quot;3&quot;
   }
]
</pre>
<p><strong>Debugging Streaming API:</strong><br />
We can use &#8220;<strong>firebug</strong>&#8221; plugin of Mozilla to check whether the http request is made or not from JQuery (comet). Following screen can give you little idea about the http (<a title="AJAX Introduction" href="http://en.wikipedia.org/wiki/Ajax_(programming)" rel="nofollow">XHR</a>) requests made from JQuery .</p>
<figure id="attachment_2849" aria-describedby="caption-attachment-2849" style="width: 574px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Firebug-Tool-Debugging-Streaming-API-of-Salesforce.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class=" wp-image-2849   " title="Firebug Tool - Debugging Streaming API of Salesforce" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/05/Firebug-Tool-Debugging-Streaming-API-of-Salesforce-1024x310.png?resize=574%2C174&#038;ssl=1" alt="Firebug Tool - Debugging Streaming API of Salesforce" width="574" height="174" /></a><figcaption id="caption-attachment-2849" class="wp-caption-text">Firebug Tool - Debugging Streaming API of Salesforce</figcaption></figure>
<p><a href="https://jitendrazaa.com/blog/wp-content/uploads/2012/05/StreaminAPI.zip">Download Static Resource used in this article for Streaming API example of salesforce</a></p>
<p><strong>Output Video of Streaming API:</strong></p>
<p><iframe loading="lazy" src="http://www.youtube.com/embed/wDLdXLee43U" frameborder="0" width="560" height="315"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/others/tips/streaming-api-using-jquery-salesforce/feed/</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2843</post-id>	</item>
		<item>
		<title>Gantt Chart in Salesforce using JQuery and JSON</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/gantt-chart-in-salesforce-using-jquery-and-json/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/gantt-chart-in-salesforce-using-jquery-and-json/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Tue, 17 Apr 2012 19:30:40 +0000</pubDate>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=2817</guid>

					<description><![CDATA[Tutorial and Example of creating the Gantt Chart in Salesforce using JQuery and JSON]]></description>
										<content:encoded><![CDATA[<p>I have searched a lot for any library available for the Gantt Chart however there are very few available on the web. Even i was not able to find out the chart in &#8220;Google API&#8221;.</p>
<p>In this article, i will delineate creating the &#8220;<strong>Gantt Chart</strong>&#8221; using JQuery and JSON. In <strong><a title="JSON output in Salesforce" href="https://jitendrazaa.com/blog/salesforce/json-output-in-visualforce/">previous article</a></strong> we have seen that how to generate JSON using Salesforce. So continuing the last article, i will use the same JSON reponse to create the &#8220;Gantt Chart&#8221;.</p>
<p><strong>What is Gantt Chart?</strong></p>
<p>A Gantt chart is a type of bar chart, developed by Henry Gantt, that illustrates a project schedule. Gantt charts illustrate the start and finish dates of the terminal elements and summary elements of a project.</p>
<p>In this example i am going to create the Gantt Chart for room reservation system. for this i am going to use the <a title="JQuery Plugin for Gantt Chart" href="http://mbielanczuk.com/?page_id=368">JQuery plugin for creating Gantt Chart found here</a>.</p>
<p>Plugin uses following JSON format :</p>
<pre class="brush: jscript; title: ; notranslate">
&#x5B;{  &quot;name&quot;  : &quot;Task#1&quot;
  , &quot;desc&quot;  : &quot; Task Desc&quot;
  , &quot;values&quot;: &#x5B;
      {  &quot;from&quot;       : &quot;/Date(1296547200000)/&quot;
       , &quot;to&quot;         : &quot;/Date(1296554400000)/&quot;
       , &quot;desc&quot;       : &quot;&lt;b&gt;Task #1&lt;br&gt;&quot;
       , &quot;customClass&quot;: &quot;ganttRed&quot; (optional)
       , &quot;label&quot;      : &quot;Task #1&quot; (optional)
      },
      {  &quot;from&quot;       : &quot;/Date(1296637200000)/&quot;
       , &quot;to&quot;         : &quot;/Date(1296649800000)/&quot;
       , &quot;desc&quot;: &quot;&lt;b&gt;Task #&lt;/b&gt;&quot;
       , &quot;customClass&quot;: &quot;ganttOrange&quot; (optional)
       , &quot;label&quot;: &quot;Task #1&quot; (optional)
      }
  ]
 },
 ...
]
</pre>
<p>However we know that the variable name &#8220;from&#8221; and &#8220;desc&#8221; are not valid in Apex because they are keyword. so as a workaround i am replacing the placeholders after the generation of JSON in previous article.<span id="more-2817"></span></p>
<p>I have added the <strong>Static Resource</strong> of name &#8220;GanttChart&#8221; which includes the jQuery and jQuery plugin to draw the Gantt Chart.</p>
<p><a href="https://jitendrazaa.com/blog/wp-content/uploads/2012/04/Gantt-Chart-Code.zip">Download Complete Source code for Gantt Chart in Salesforce with Static resources</a></p>
<p>following visualforce page renders the Grantt chart on the basis of JSON passed:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;apex:page standardStylesheets=&quot;false&quot; sidebar=&quot;false&quot;&gt;

&lt;apex:stylesheet value=&quot;{!URLFOR($Resource.GanttChart, 'style.css')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.GanttChart, 'js/jquery-1.5.1.min.js')}&quot;/&gt;
&lt;apex:includeScript value=&quot;{!URLFOR($Resource.GanttChart, 'js/jquery.fn.gantt.js')}&quot;/&gt;

&lt;div class=&quot;gantt&quot; /&gt;

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

$gc = jQuery.noConflict();

function getHostName()
{
    var p = $gc(location).attr('href');
    pathArray = p.split( '/' );
    var protocol = pathArray&#x5B;0];
    var host = pathArray&#x5B;2];
    return protocol+'//'+host;
}

	var jsonDataURL = getHostName()+'/apex/GanttChartData?core.apexpages.devmode.url=0';

	$gc(function () {
     	$gc(&quot;.gantt&quot;).gantt({source: jsonDataURL, navigate: 'scroll', scale: 'hours', maxScale: 'hours', minScale: 'hours', hollydays: &#x5B;&quot;/Date(1293836400000)/&quot;]});
     });

&lt;/script&gt;

&lt;/apex:page&gt;
</pre>
<p>Gantt Chart will be rendered in div tag having class name as &#8220;<strong>gantt</strong>&#8220;.</p>
<p>Note : We have to Remember one thing that the Date must be passed in format of &#8220;/Date(VALUE_IN_MIL_SECOND)/&#8221; because regular expression is used by the plugin to identify and convert back date to javascript format.</p>
<p>Refer <a title="Salesforce Date time methods" href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm">this API for Datetime methods of the Salesforce</a></p>
<p>The output will look like:</p>
<figure id="attachment_2818" aria-describedby="caption-attachment-2818" style="width: 588px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/04/Gantt-Chart-in-Salesforce.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class=" wp-image-2818 " title="Gantt Chart in Salesforce" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/04/Gantt-Chart-in-Salesforce.png?resize=588%2C199&#038;ssl=1" alt="Gantt Chart in Salesforce" width="588" height="199" /></a><figcaption id="caption-attachment-2818" class="wp-caption-text">Gantt Chart in Salesforce</figcaption></figure>
<p><a href="https://jitendrazaa.com/blog/wp-content/uploads/2012/04/Gantt-Chart-Code.zip">Download Complete Source code for Gantt Chart in Salesforce with Static resources</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/gantt-chart-in-salesforce-using-jquery-and-json/feed/</wfw:commentRss>
			<slash:comments>51</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2817</post-id>	</item>
		<item>
		<title>Handling Colon in Element ID in JQuery &#8211; Visualforce problem</title>
		<link>https://www.jitendrazaa.com/blog/others/tips/handling-colon-in-element-id-in-jquery-visualforce-problem/</link>
					<comments>https://www.jitendrazaa.com/blog/others/tips/handling-colon-in-element-id-in-jquery-visualforce-problem/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Tue, 07 Feb 2012 19:25:12 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=2706</guid>

					<description><![CDATA[Resolving the JQuery error when the Element ID contains colon with Live Demo]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Today i came across very known problem of jQuery and thought of sharing same with everyone. In Salesforce the element id is in the format of &#8220;<strong>j_id0:j_id3:j_id4:c_txt</strong>&#8220;. In previous post we have already discussed about getting <a title="Get Element ID in Visualforce - Salesforce" href="https://jitendrazaa.com/blog/salesforce/get-dom-elementid-of-the-visualforce-components/" target="_blank">the elementId in Visualforce</a>.<br />
When i tried to find the element in JQuery like <strong>$(&#8216;#j_id0:j_id3:j_id4:c_txt&#8217;)</strong>, i was getting the error on JavaScript console of the browser. After few searches, i got to know that this is known problem and faced by many of the developers.</p>
<h2 style="text-align: left;"><a href="https://jitendrazaa.com/blog/wp-content/uploads/2012/02/HandlingColoninJQuery.htm">Live Demo</a></h2>
<p style="text-align: justify;"><span id="more-2706"></span>So here i came with few workarounds as follow:</p>
<p><strong>1. Using Traditional JavaScript:</strong><br />
This was the first option in mind and worked very well. We have to use it very straightforward as always,</p>
<pre class="brush: jscript; title: ; notranslate">
var ele = document.getElementById(&quot;abc:xyz&quot;);
</pre>
<p><strong>2. Using JQuery Approach 1:</strong><br />
In this approach instead of searching by $(&#8220;#abc:xyz&#8221;), we have to search like</p>
<pre class="brush: jscript; title: ; notranslate">
var ele = $('&#x5B;id=&quot;abc:xyz&quot;]');
</pre>
<p><strong>3. Using JQuery Approach 2:</strong><br />
Use double slash &#8220;\&#8221; in front of colon which will work as escape sequence</p>
<pre class="brush: jscript; title: ; notranslate">
var ele = $(&quot;#abc\:xyz&quot;);
</pre>
<p><strong>4. Using JQuery and JavaScript both:</strong><br />
We will find the element by traditional JavaScript and then assign it to the JQuery like</p>
<pre class="brush: jscript; title: ; notranslate">
var ele = document.getElementById('abc:xyz');
ele = $(ele).val();
</pre>
<p><span style="text-decoration: underline;">Complete Source Code demonstrating the scenario:</span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;
Handling Colon in Element ID in JQuery | ShivaSoft
&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js&quot;&gt;&lt;/script&gt;
&lt;style&gt;
.myButton {
	-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
	-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
	box-shadow:inset 0px 1px 0px 0px #ffffff;
	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );
	background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
	background-color:#ededed;
	-moz-border-radius:6px;
	-webkit-border-radius:6px;
	border-radius:6px;
	border:1px solid #dcdcdc;
	display:inline-block;
	color:#777777;
	font-family:arial;
	font-size:15px;
	font-weight:bold;
	padding:6px 24px;
	text-decoration:none;
	text-shadow:1px 1px 0px #ffffff;
	cursor:pointer;
}.myButton:hover {
	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed) );
	background:-moz-linear-gradient( center top, #dfdfdf 5%, #ededed 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed');
	background-color:#dfdfdf;
}.myButton:active {
	position:relative;
	top:1px;
}
code
{
	color:green;
}
.error
{
	color:red;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input value=&quot;ShivaSoft&quot; type=&quot;text&quot; size=&quot;30&quot; id=&quot;abc:xyz&quot; /&gt; &lt;br /&gt;
&lt;input class=&quot;myButton&quot; type=&quot;button&quot; value=&quot;Clear Ans&quot; onclick=&quot;clearAns()&quot; /&gt;
&lt;br /&gt;

&lt;input class=&quot;myButton&quot; type=&quot;button&quot; value=&quot;Simple jQuery&quot; onclick=&quot;simpleJQuery()&quot; /&gt;
Using &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;code class=&quot;error&quot;&gt;$(&quot;#abc:xyz&quot;)&lt;/code&gt;
&lt;br /&gt;

&lt;input class=&quot;myButton&quot; type=&quot;button&quot; value=&quot;Traditional JS&quot; onclick=&quot;simpleJS()&quot; /&gt;
Using &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;code&gt; document.getElementById(&quot;abc:xyz&quot;)&lt;/code&gt;
&lt;br /&gt;

&lt;input class=&quot;myButton&quot; type=&quot;button&quot; value=&quot;JQuery-Approach1&quot; onclick=&quot;app1()&quot; /&gt;
Using &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;code&gt;$('&#x5B;id=&quot;abc:xyz&quot;]')&lt;/code&gt;
&lt;br /&gt;

&lt;input class=&quot;myButton&quot; type=&quot;button&quot; value=&quot;JQuery-Approach2&quot; onclick=&quot;app2()&quot; /&gt;
Using double slash (Escape sequence) in front of colon &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;code&gt;$(&quot;#abc\:xyz&quot;)&lt;/code&gt;
&lt;br /&gt;

&lt;input class=&quot;myButton&quot; type=&quot;button&quot; value=&quot;JQuery-Approach3&quot; onclick=&quot;app3()&quot; /&gt;
This is workaround. Get element by Javascript and pass to jQuery  &amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;code&gt;
&lt;pre&gt;
	var ans = document.getElementById('abc:xyz');
	ans = $(ans).val();
&lt;/pre&gt;
&lt;/code&gt;
&lt;br /&gt;

&lt;hr /&gt;
Output -
&lt;div id=&quot;divOut&quot; style=&quot;background-color:yellow&quot; /&gt;

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

function app3()
{
	clearAns();
	var ans = document.getElementById('abc:xyz');
	ans = $(ans).val();
	printAns(ans);
}

function app2()
{
	clearAns();
	var ans = $(&quot;#abc\:xyz&quot;).val();
	printAns(ans);
}

function app1()
{
	clearAns();
	var ans = $('&#x5B;id=&quot;abc:xyz&quot;]').val();
	printAns(ans);
}

function simpleJQuery()
{
	clearAns();
	var ans = $(&quot;#abc:xyz&quot;).val();
	printAns(ans);
}

function simpleJS()
{
	clearAns();
	var ans = document.getElementById(&quot;abc:xyz&quot;).value;
	printAns(ans);
}

function clearAns()
{
	$(&quot;#divOut&quot;).html('');
}
function printAns(ans)
{
	var ansDiv = $(&quot;#divOut&quot;);
	ansDiv.html(ans);
	ansDiv.css(&quot;background-color&quot;,randColor());
}
function randColor()
{
    colors = &#x5B;'orange', '#ccc', 'blue', 'green','yellow','lightGreen']
    return colors&#x5B;Math.floor(Math.random()*colors.length)];
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2><a href="https://jitendrazaa.com/blog/wp-content/uploads/2012/02/HandlingColoninJQuery.htm">Live Demo</a></h2>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/others/tips/handling-colon-in-element-id-in-jquery-visualforce-problem/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2706</post-id>	</item>
		<item>
		<title>Create Simple Drag and Drop Widget like iGoogle using JQuery</title>
		<link>https://www.jitendrazaa.com/blog/webtech/web/create-simple-drag-and-drop-widget-like-igoogle-using-jquery/</link>
					<comments>https://www.jitendrazaa.com/blog/webtech/web/create-simple-drag-and-drop-widget-like-igoogle-using-jquery/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Thu, 19 Jan 2012 19:10:27 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=2657</guid>

					<description><![CDATA[Live Demo with source code on creating Simple Drag and Drop Widget using JQuery plugin like iGoogle ]]></description>
										<content:encoded><![CDATA[<p>After reading this post you will come to know that how easy its to create the Drag and Drop functionality using JQuery.</p>
<p>To run this example you will need two javascript libraries as follow:</p>
<ol>
<li><a href="http://jquery.com/">JQuery</a></li>
<li><a href="http://jqueryui.com/">JQueryUI</a></li>
</ol>
<figure id="attachment_2661" aria-describedby="caption-attachment-2661" style="width: 591px" class="wp-caption aligncenter"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/01/jQuery-Drag-and-Drop-Widgets.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class=" wp-image-2661  " title="jQuery Drag and Drop Widgets" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2012/01/jQuery-Drag-and-Drop-Widgets.png?resize=591%2C234&#038;ssl=1" alt="jQuery Drag and Drop Widgets" width="591" height="234" /></a><figcaption id="caption-attachment-2661" class="wp-caption-text">jQuery Drag and Drop Widgets</figcaption></figure>
<p><span id="more-2657"></span></p>
<h3><a href="https://jitendrazaa.com/blog/wp-content/uploads/demos/DragAndDrop/index.html">You can see the complete working demo here</a></h3>
<p>Lets say you want to create the widget in two columns, so first create two DIV tags as shown below:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;column1&quot; class=&quot;column&quot;&gt;
&lt;!-- Widgets code here --&gt;
&lt;/div&gt;

&lt;div id=&quot;column2&quot;  class=&quot;column&quot;&gt;
&lt;!-- Widgets code here --&gt;
&lt;/div&gt;
</pre>
<p>We are assuming that we can drag the elements from column1 to column2 and vice verse.</p>
<p>Now we will create the actual element which can be drag-gable.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;column1&quot; class=&quot;column&quot;&gt;
	&lt;div class=&quot;dragbox&quot; id=&quot;item1&quot; &gt;
		&lt;h2&gt;Handle 1
		  &lt;a href=&quot;#&quot; class=&quot;delete opIcons&quot;&gt; &lt;/a&gt;
		  &lt;a href=&quot;#&quot; class=&quot;maxmin opIcons&quot;&gt; &lt;/a&gt;

		&lt;/h2&gt;
		&lt;div class=&quot;dragbox-content&quot; &gt;
			&lt;!-- Panel Content Here --&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;column2&quot;  class=&quot;column&quot;&gt;
	&lt;div class=&quot;dragbox&quot; id=&quot;item2&quot; &gt;
		&lt;h2&gt;Handle 2
		  &lt;a href=&quot;#&quot; class=&quot;delete opIcons&quot;&gt; &lt;/a&gt;
		  &lt;a href=&quot;#&quot; class=&quot;maxmin opIcons&quot;&gt; &lt;/a&gt;

		&lt;/h2&gt;
		&lt;div class=&quot;dragbox-content&quot; &gt;
			&lt;!-- Panel Content Here --&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>As you can see &lt;h2&gt; tag is used to create the heading and there are two &lt;a&gt; (anchor) tags, one for delete and one for toggle.</p>
<p>Now its time to write the JQuery code to drag and drop the &lt;div&gt; tag with <strong>class=&#8221;dragbox&#8221;</strong></p>
<pre class="brush: jscript; title: ; notranslate">
$(
function(){
	$('a.maxmin').click(
	function(){
		$(this).parent().siblings('.dragbox-content').toggle();
	});

	$('a.delete').click(
	function(){
		var sel = confirm('do you want to delete the widget?');
		if(sel)
		{
			//del code here
		}
	}
	);

	$('.column').sortable({
	connectWith: '.column',
	handle: 'h2',
	cursor: 'move',
	placeholder: 'placeholder',
	forcePlaceholderSize: true,
	opacity: 0.4,
	stop: function(event, ui)
		{
			$(ui.item).find('h2').click();
			var sortorder='';

			$('.column').each(function(){
				var itemorder=$(this).sortable('toArray');
				var columnId=$(this).attr('id');
				sortorder+=columnId+'='+itemorder.toString()+'&amp;';
			});
			sortorder = sortorder.substring(0, sortorder.length - 1)
			alert('SortOrder: '+sortorder);

		}
	}).disableSelection();
});
</pre>
<p style="text-align: justify;">As you can see, on dom ready event using $() &#8211; which is equal to &#8220;$.ready()&#8221;, we have written the code like $(&#8216;.column&#8217;).sortable(&#8230;) which will perform the drag and drop functionality. the &#8220;sortable&#8221; functionality is used to save the state of the widget in database so that next time you can load the widget in order which they are previously for this you will need to do some extra code here. The sort result is displayed using alert after element drop.</p>
<p style="text-align: justify;">For the delete action, i have written the comment where server request can be called using Ajax to delete the widget. With the help of below CSS this example will be completed with nice look and feel.</p>
<pre class="brush: css; title: ; notranslate">
.column{
	width:49%;
	margin-right:.5%;
	min-height:300px;
	background:#fff;
	float:left;
}
.column .dragbox{
	margin:5px 2px  20px;
	background:#fff;
	position:&quot;relative&quot;;
	border:1px solid #946553;
	-moz-border-radius:5px;
	-webkit-border-radius:5px;
}
.column .dragbox h2{
	margin:0;
	font-size:12px;
	background:#946553;
	color:#fff;
	border-bottom:1px solid #946553;
	font-family:Verdana;
	cursor:move;
	padding:5px;
}

.dragbox-content{
	background:#fff;
	min-height:100px; margin:5px;
	font-family:'Lucida Grande', Verdana; font-size:0.8em; line-height:1.5em;
}
.column  .placeholder{
	background: #EED5B7;
	border:1px dashed #946553;
}

.opIcons
{
background-image: url('iconSpirite.gif')!important;
background-repeat: no-repeat;
float:right;
height:13px;
width:13px;
margin:0px 2px;
}

.maxmin
{
	background-position:-26px 1px;
}

.delete
{
	background-position:-269px center;
	padding-top:1px;
}
</pre>
<h3><a href="https://jitendrazaa.com/blog/wp-content/uploads/demos/DragAndDrop/index.html">You can see the complete working demo here</a></h3>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/webtech/web/create-simple-drag-and-drop-widget-like-igoogle-using-jquery/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2657</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-06-03 05:21:38 by W3 Total Cache
-->