Browse files

Refer to .map() in entry and vice versa.

Fixes #46.
  • Loading branch information...
1 parent 26f642c commit 90dc60066be70f1c31340950a1ba236711c64dd6 @kswedberg kswedberg committed Jul 17, 2012
Showing with 7 additions and 5 deletions.
  1. +2 −1 entries/
  2. +5 −4 entries/map.xml
@@ -21,6 +21,7 @@
<desc>Translate all items in an array or object to new array of items.</desc>
+ <p>If you wish to process a jQuery object — for example, <code>$('div').map( callback );</code> — use <a href="/">.map()</a> instead. </p>
<p>The <code>$.map()</code> method applies a function to each item in an array or object and maps the results into a new array. <strong>Prior to jQuery 1.6</strong>, <code>$.map()</code> supports traversing <em>arrays only</em>. <strong>As of jQuery 1.6</strong> it also traverses objects.</p>
<p>Array-like objects &#x2014; those with a <code>.length</code> property <em>and</em> a value on the <code>.length - 1</code> index &#x2014; must be converted to actual arrays before being passed to <code>$.map()</code>. The jQuery library provides <a href="">$.makeArray()</a> for such conversions.</p>
@@ -138,4 +139,4 @@ array = $.map(array, function(a, index) {
<category slug="utilities"/>
<category slug="version/1.0"/>
<category slug="version/1.6"/>
@@ -9,7 +9,8 @@
<desc>Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.</desc>
- <p>As the return value is a jQuery-wrapped array, it's very common to <code>get()</code> the returned object to work with a basic array.</p>
+ <p>If you wish to process a plain array or object, use the <a href="/"></a> instead. </p>
+ <p>As the return value is a jQuery object, which contains an array, it's very common to call <code>.get()</code> on the result to work with a basic array.</p>
<p>The <code>.map()</code> method is particularly useful for getting or setting the value of a collection of elements. Consider a form with a set of checkboxes in it:</p>
&lt;form method="post" action=""&gt;
@@ -33,10 +34,10 @@
- <p>We can get a comma-separated list of checkbox <code>ID</code>s:</p>
+ <p>To get a comma-separated list of checkbox <code>ID</code>s:</p>
<pre><code>$(':checkbox').map(function() {
- }).get().join(',');</code></pre>
+ }).get().join();</code></pre>
<p>The result of this call is the string, <code>"two,four,six,eight"</code>.</p>
<p>Within the callback function, <code>this</code> refers to the current DOM element for each iteration. The function can return an individual data item or an array of data items to be inserted into the resulting set. If an array is returned, the elements inside the array are inserted into the set. If the function returns <code>null</code> or <code>undefined</code>, no element will be inserted.</p>
@@ -133,4 +134,4 @@ input { clear:left}
<category slug="traversing/filtering"/>
<category slug="version/1.2"/>

0 comments on commit 90dc600

Please sign in to comment.