• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Using jQuery Templates
 

Using jQuery Templates

on

  • 2,282 views

This presentation by Dan Wahlin covers the fundamentals needed to get started using jQuery Templates. By using templates you can significantly reduce the amount of JavaScript that you write and keep ...

This presentation by Dan Wahlin covers the fundamentals needed to get started using jQuery Templates. By using templates you can significantly reduce the amount of JavaScript that you write and keep your code-base more maintainable.

Statistics

Views

Total Views
2,282
Views on SlideShare
2,281
Embed Views
1

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 1

http://localhost 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Show John Resig's Micro-Template MIX 09 08/13/11 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Show John Resig's Micro-Template MIX 09 08/13/11 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Tech Ed North America 2010 08/13/11 19:49 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Tech Ed North America 2010 08/13/11 19:49 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Tech Ed North America 2010 08/13/11 19:49 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Tech Ed North America 2010 08/13/11 19:49 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Tech Ed North America 2010 08/13/11 19:49 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Using jQuery Templates Using jQuery Templates Presentation Transcript

  • jQuery Templates And HTML5 Dan Wahlin
  • Contact Info
    • Blog
    • http://weblogs.asp.net/dwahlin
    • Twitter
    • @DanWahlin
    • Email:
    • [email_address]
  • Agenda
    • Why use Templates?
    • Introduction to jQuery Templates
    • jQuery Templates in Action
  • Client-Side Template Solutions
    • HTML templates simplify building AJAX applications:
      • Minimize custom JavaScript
      • Simplify Maintenance
    • Several HTML template solutions exist:
      • John Resig's JavaScript Micro-Templating
      • jBind
      • Chain.js
      • jQuery Templates
  • Maintainable Code?
    • var total;
    • $(order.Items).each(function()
    • {
    • var item = this;
    • $('#item' + item.ID) .append('<div>' + item.Title + '</div>');
    • total += item.Total;
    • });
    • $('#total').html(total);
  • Agenda
    • Why use Templates?
    • Introduction to jQuery Templates
    • jQuery Templates in Action
  • jQuery Template Tokens rev 1.0/0510 Chapter 5- {{if}}..{{/if}} {{each}}..{{/each}} ${ Property } {{tmpl}} {{wrap}} {{html}}
  • jQuery Template Container
    • <script id=&quot;MyTemplate&quot; type=&quot;text/x-jquery-tmpl&quot; > ...
    • </script>
  • jQuery Template Example
    • <script id=&quot;MyTemplate&quot; type=&quot;text/x-jquery-tmpl&quot;>
    • <div id=&quot;DeliveryDiv&quot;> ${ DeliveryName } </div>
    • </script>
  • Applying a Template
      • <script id=&quot;MyTemplate&quot; type=&quot;text/x-jquery-tmpl&quot;>
      • <div id=&quot;DeliveryDiv&quot;> ${ DeliveryName} </div>
      • </script>
      • <div id=&quot;OutputDiv&quot;></div>
      • $('#MyTemplate') .tmpl(json) .appendTo('#OutputDiv');
  • Adding Conditional Logic
        • {{if MainItems == null }}
        • <tr>
        • <td>No items selected</td>
        • </tr>
        • {{else}}
        • <tr>
        • <td>${product.Name}</td>
      • </tr>
      • {{/if}}
  • Working with Loops
      • {{if MainItems == null }}
      • <tr>
      • <td>No items selected</td>
      • </tr>
      • {{else}}
      • {{each(i,mmi) MainItems}}
      • <tr>
      • <td>${mmi.Name}</td>
      • </tr>
      • {{/each}}
      • {{/if}}
  • $index and $value Keywords
      • {{each MainItems}}
      • <tr>
      • <td>
      • ${$index}: ${$value.Name} </td>
      • </tr>
      • {{/each}}
  • Agenda
    • Why use Templates?
    • Introduction to jQuery Templates
    • jQuery Templates in Action
  •  
  • Contact Info
    • Blog
    • http://weblogs.asp.net/dwahlin
    • Twitter
    • @DanWahlin
    • Email:
    • [email_address]