<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/11/prototypejs-primer.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2008://34.34072-</id>
  <updated>2009-11-16T15:25:16Z</updated>
  <title>Comments for Prototype.js Utility Functions Primer (http://www.insideria.com/2008/11/prototypejs-primer.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2008://34.34072</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/11/prototypejs-primer.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=34072" title="Prototype.js Utility Functions Primer" />
    <published>2008-11-11T17:00:00Z</published>
    <updated>2008-11-11T16:22:58Z</updated>
    <title>Prototype.js Utility Functions Primer</title>
    <summary>Prototype is one of the more popular JavaScript libraries and is used on a number of popular HTML based web applications, like Twitter and Apple&apos;s mobile me.</summary>
    <author>
      <name>Jeremy Bierly</name>
      
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<p><a href="http://www.prototypejs.org/">Prototype</a> is one of the more popular JavaScript libraries and is used on a number of popular HTML based web applications, like <a href="http://twitter.com/">Twitter</a> and Apple's <a href="http://me.com">mobile me</a>.</p>

<p>Prototype.js began as a spin-off of <a href="http://www.rubyonrails.org/">Ruby on Rails</a>, but it can be used with any web development platform.</p>

<p>Here is a great introduction to prototype.js from <a href="http://www.oreillynet.com/pub/au/2727">Scott Raymond</a>:</p>

<blockquote>The Prototype JavaScript framework by Sam Stephenson is designed to ease development of dynamic web applications. It extends core JavaScript classes and adds new ones to provide powerful features, especially for working with Ajax and manipulating DOM elements. In many ways, it also bridges part of the gap between the JavaScript and Ruby languages&#8212;particularly by borrowing ideas from Ruby's Enumerable module.</blockquote>

<p>The most useful functions in prototype are the "utility methods".</p>

<p>$(element) is essentially document.getElementById on steroids, it returns and extended element that can use any of the additional prototype methods.</p>

<p>For example, if you would like to hide an element on your page, you could write $(element).hide(); instead of document.getElementById(element).style.display = 'none';</p>

<p>the double dollar function - $$(CSS Selector) - is also a very useful function.  It returns a collection of extended elements that use the CSS Rule.  In addition to CSS Selectors the double dollar function can can return an array.</p>

<p>For example if you wanted to return an array of every link on your page that has an href="#", you could use $$('a[href="#"]').</p>

<p>The $w() function lets you create an array without splitting up your items.  So you could use $w('dogs cats cows pigs') instead of ['dogs', 'cats', 'cows', pigs'].</p>

<p>the $A() is another very useful array function.  If you want to return an array of elements, but do not want to extend the elements then you can use $A(document.getElementsByTagName('tag')).</p>

<p>$F(element) will return the value of from a formField.  Remember to use the elements id, not name.</p>

<p>$H() is the prototype hash function.  I'll talk about the has function in more detail in later blog posts.</p>

<p>$R() is the prototype range function.  It's most commonly used for integer ranges.</p>

<p>For example $R(1,5) would give you a range from 1 to 5.</p>

<p>There you have the Prototype Utility Functions.</p>

<p>In later blog posts, I'll walk through the Prototype.js AJAX functions, which dramatically simplify and streamline writing AJAX calls.</p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.34072-comment:2068535</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.34072" type="text/html" href="http://www.insideria.com/2008/11/prototypejs-primer.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/11/prototypejs-primer.html#comment-2068535" />
    <title>Comment from beiks on 2009-07-18</title>
    <author>
        <name>beiks</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>tephenson is designed to ease development of dynamic web applications. It extends core JavaScript classes and adds new ones to provide powerful features, especially for <br />
<a href="http://www.mustuniversity.com/Programs/Degree/Masters-Degree.html">online Master Degree</a> & <a href="http://www.musthighschool.com/Must/DistanceLearning.asp">distance learning high school</a>working with Ajax and manipulating DOM elements. In many ways, it also bridges part of the gap between the JavaScript and Ruby languages—particularly by borrowing ideas from Ruby's Enumerable module.</p>]]>
    </content>
    <published>2009-07-18T09:51:52Z</published>
  </entry>

</feed
