@@ -358,27 +358,29 @@ will be show next):
358358
359359..code-block ::javascript
360360
361+ var $collectionHolder;
362+
361363// setup an "add a tag" link
362- var addTagLink= $ (' <a href="#">Add a tag</a>' );
363- var newLinkLi= $ (' <li></li>' ).append (addTagLink);
364+ var $ addTagLink= $ (' <a href="#">Add a tag</a>' );
365+ var $ newLinkLi= $ (' <li></li>' ).append ($ addTagLink);
364366
365367jQuery (document ).ready (function () {
366368// Get the ul that holds the collection of tags
367- var collectionHolder= $ (' ul.tags' );
369+ $ collectionHolder= $ (' ul.tags' );
368370
369371// add the "add a tag" anchor and li to the tags ul
370- collectionHolder .append (newLinkLi);
372+ $ collectionHolder .append ($ newLinkLi);
371373
372374// count the current form inputs we have (e.g. 2), use that as the new
373375// index when inserting a new item (e.g. 2)
374- collectionHolder .data (' index' ,collectionHolder .find (' :input' ).length );
376+ $ collectionHolder .data (' index' ,$ collectionHolder .find (' :input' ).length );
375377
376- addTagLink .on (' click' ,function (e ) {
378+ $ addTagLink .on (' click' ,function (e ) {
377379// prevent the link from creating a "#" on the URL
378380e .preventDefault ();
379381
380382// add a new tag form (see next code block)
381- addTagForm (collectionHolder, newLinkLi);
383+ addTagForm ($ collectionHolder,$ newLinkLi);
382384 });
383385 });
384386
@@ -393,23 +395,23 @@ one example:
393395
394396..code-block ::javascript
395397
396- function addTagForm (collectionHolder ,newLinkLi ) {
398+ function addTagForm ($ collectionHolder ,$ newLinkLi ) {
397399// Get the data-prototype explained earlier
398- var prototype= collectionHolder .data (' prototype' );
400+ var prototype= $ collectionHolder .data (' prototype' );
399401
400402// get the new index
401- var index= collectionHolder .data (' index' );
403+ var index= $ collectionHolder .data (' index' );
402404
403405// Replace '$$name$$' in the prototype's HTML to
404406// instead be a number based on how many items we have
405407var newForm= prototype .replace (/ \$\$ name\$\$ / g , index);
406408
407409// increase the index with one for the next item
408- collectionHolder .data (' index' , index+ 1 );
410+ $ collectionHolder .data (' index' , index+ 1 );
409411
410412// Display the form in the page in an li, before the "Add a tag" link li
411- var newFormLi= $ (' <li></li>' ).append (newForm);
412- newLinkLi .before (newFormLi);
413+ var $ newFormLi= $ (' <li></li>' ).append ($ newForm);
414+ $ newLinkLi .before ($ newFormLi);
413415 }
414416
415417 ..note ::