@@ -358,27 +358,27 @@ will be show next):
358358
359359.. code-block :: javascript
360360
361- // Get the ul that holds the collection of tags
362- var collectionHolder = $ (' ul.tags' );
363-
364361 // setup an "add a tag" link
365- var $ addTagLink = $ (' <a href="#" class="add_tag_link">Add a tag</a>' );
366- var $ newLinkLi = $ (' <li></li>' ).append ($ addTagLink);
362+ var addTagLink = $ (' <a href="#" class="add_tag_link">Add a tag</a>' );
363+ var newLinkLi = $ (' <li></li>' ).append (addTagLink);
367364
368365 jQuery (document ).ready (function () {
366+ // Get the ul that holds the collection of tags
367+ var collectionHolder = $ (' ul.tags' );
368+
369369 // add the "add a tag" anchor and li to the tags ul
370- collectionHolder .append ($ newLinkLi);
370+ collectionHolder .append (newLinkLi);
371371
372372 // count the current form inputs we have (e.g. 2), use that as the new
373373 // index when inserting a new item (e.g. 2)
374374 collectionHolder .data (' index' , collectionHolder .find (' :input' ).length );
375375
376- $ addTagLink .on (' click' , function (e ) {
376+ addTagLink .on (' click' , function (e ) {
377377 // prevent the link from creating a "#" on the URL
378378 e .preventDefault ();
379379
380380 // add a new tag form (see next code block)
381- addTagForm (collectionHolder, $ newLinkLi);
381+ addTagForm (collectionHolder, newLinkLi);
382382 });
383383 });
384384
@@ -393,7 +393,7 @@ one example:
393393
394394.. code-block :: javascript
395395
396- function addTagForm (collectionHolder , $ newLinkLi ) {
396+ function addTagForm (collectionHolder , newLinkLi ) {
397397 // Get the data-prototype explained earlier
398398 var prototype = collectionHolder .data (' prototype' );
399399
@@ -408,8 +408,8 @@ one example:
408408 collectionHolder .data (' index' , index + 1 );
409409
410410 // 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);
411+ var newFormLi = $ (' <li></li>' ).append (newForm);
412+ newLinkLi .before (newFormLi);
413413 }
414414
415415 .. note ::
0 commit comments