{"id":3642,"date":"2011-04-14T21:41:06","date_gmt":"2011-04-14T16:11:06","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=3642"},"modified":"2016-09-01T16:04:01","modified_gmt":"2016-09-01T10:34:01","slug":"getting-started-with-extjs","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/getting-started-with-extjs\/","title":{"rendered":"Getting started with extJS"},"content":{"rendered":"<p>Ext.JS JavaScript Framework a <a title=\"react.js development\" href=\"http:\/\/www.tothenew.com\/front-end-angularjs-development\">cross-browser JavaScript<\/a> library for building rich internet applications. It is built for developing high performance, customizable UI widgets and features a well designed, documented and extensible Component model. It is available in both Commercial and Open Source licenses are available.<\/p>\n<p><strong>Step 1:<\/strong><br \/>\nFirst download the source css and js<\/p>\n<p><strong>Step 2:<\/strong><br \/>\nInclude the following css and js as<\/p>\n<p>[html]<br \/>\n&lt;script src=&quot;..\/..\/adapter\/ext\/ext-base.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;<br \/>\n&lt;script src=&quot;..\/..\/ext-all.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;<br \/>\n[\/html]<\/p>\n<p>Now start writing the code in script tag or make js file.<br \/>\njQuery and extJS comparisions:<\/p>\n<p><strong>Document is ready<\/strong><\/p>\n<p>[html]<br \/>\n\/\/document is raedy in jQuery<br \/>\n&lt;script type=&quot;text\/javascript&quot;&gt;\/\/ &lt;![CDATA[<br \/>\n$(document).ready(function() {<br \/>\n  \/\/ do stuff when DOM is ready<br \/>\n});<br \/>\n\/\/ ]]&gt;&lt;\/script&gt;<\/p>\n<p>\/\/in extJS<br \/>\n&lt;script type=&quot;text\/javascript&quot;&gt;\/\/ &lt;![CDATA[<br \/>\nExt.onReady(function() {<br \/>\n  \/\/ do stuff when DOM is ready<br \/>\n});<br \/>\n\/\/ ]]&gt;&lt;\/script&gt;<br \/>\n[\/html]<\/p>\n<p><strong>Selecting elements<\/strong><\/p>\n<p>[html]<br \/>\n\/\/ Selecting by ID in jQuery<br \/>\nvar myDiv = $(&quot;#element-id&quot;);<br \/>\n\/\/ Selecting by ID in Extjs<br \/>\nvar myDiv = Ext.get(&#8216;element-id&#8217;);<br \/>\n\/\/ Perform some action on it<br \/>\n\/\/ Add a class<br \/>\nmyDiv.addClass(&#8216;my-class&#8217;);<br \/>\n\/\/ Set the width 100 px,<br \/>\n\/\/ true is for applying default animation on change<br \/>\nmyDiv.setWidth(100, true);<br \/>\n\/\/ Retrive some information of the element<br \/>\n\/\/ Get the elements box info as object {x, y, width, height}<br \/>\nvar box = myDiv.getBox();<\/p>\n<p>extJS:<\/p>\n<p>\/\/ Select elements with CSS Selector<br \/>\nvar imgs = Ext.select(&quot;#my-div div.member img&quot;);<br \/>\n\/\/ or select directly from an existing element<br \/>\nvar members = Ext.get(&#8216;my-div&#8217;);<br \/>\nvar imgs = members.select(&#8216;div.member img&#8217;);<br \/>\n\/\/ Now, any Ext.Element actions can be performed on all the elements in this collection<br \/>\n[\/html]<\/p>\n<p><strong>Dom scripting<\/strong><\/p>\n<p>[html]<br \/>\nvar el1 = Ext.get(&quot;my-1st-div&quot;);<br \/>\nvar el2 = Ext.get(&quot;my-2nd-div&quot;);<br \/>\n\/\/ Appending elements<br \/>\nel1.appendChild(&quot;A new paragraph&quot;).appendTo(el2)<br \/>\n\/\/ Replcing, removing<br \/>\nvar el3 = Ext.get(&quot;my-3rd-div&quot;);<br \/>\nExt.get(&quot;my-4th-div&quot;).replace(el3).insertAfter(el2);<br \/>\nel2.remove()<br \/>\n[\/html]<\/p>\n<p><strong>Events<\/strong><\/p>\n<p>[html]<br \/>\n\/\/ Binding an event in jQuery<br \/>\n$(&quot;.btn&quot;).click(function() {<br \/>\n\/\/ Do something on button click<br \/>\n});<\/p>\n<p>\/\/ Binding an event in Extjs<br \/>\nExt.select(&#8216;.btn&#8217;).on(&#8216;click&#8217;, function() {<br \/>\n\/\/ Do something on button click<br \/>\n});<br \/>\n[\/html]<\/p>\n<p><strong>Ajax<\/strong><\/p>\n<p>[html]<br \/>\n\/\/ Basic request in jQuery<br \/>\n$.ajax({<br \/>\ntype: &quot;POST&quot;,<br \/>\nurl: url,<br \/>\ndata: { x: &#8216;y },<br \/>\nsuccess: function(msg){<br \/>\nalert( &quot;Data Saved: &quot; + msg );<br \/>\n}<br \/>\n});<\/p>\n<p>\/\/ Basic request in Ext<br \/>\nExt.Ajax.request({<br \/>\nurl: url,<br \/>\nparams: { x: &#8216;abc&#8217; },<br \/>\nsuccess: function(msg){<br \/>\nalert( &quot;Data Saved: &quot; + msg );<br \/>\n}<br \/>\n});<br \/>\n[\/html]<\/p>\n<p>Here, I have listed the basic difference between jQuery and extJS for complete reference<br \/>\nhope it helps you guys \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ext.JS JavaScript Framework a cross-browser JavaScript library for building rich internet applications. It is built for developing high performance, customizable UI widgets and features a well designed, documented and extensible Component model. It is available in both Commercial and Open Source licenses are available. Step 1: First download the source css and js Step 2: [&hellip;]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":10},"categories":[7],"tags":[643,55],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3642"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=3642"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3642\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=3642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=3642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=3642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}