Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

CHAPTER 25: Refactoring the Example: Par... > Adding the Shopping Basket - Pg. 732

CHAPTER 25 REFACTORING THE EXAMPLE: PART III }); }); </script> <script id="flowerTmpl" type="text/x-jquery-tmpl"> <div class="dcell"> <img src="${product}.png"/> <label for="${product}">${name}:</label> <input name="${product}" value="0" /> </div> </script> </head> <body> <h1>Jacqui's Flower Shop</h1> <form method="post" action=""> <div id="products"></div> <div id="buttonDiv"><button type="submit">Place Order</button></div> </form> </body> </html> I have rewritten the function passed to the getJSON method to create the accordion, including constructing the element structure and calling the accordion method. The new implementation uses the JSON data object to extract the names of the flowers for the section titles but still uses the data template plugin to generate the HTML elements (that are then sliced and placed into wrapper div elements to suit the accordion). You can see how the document appears before and after the addition of the call to the accordion method in Figure 25-3.