Programming JavaScript Applications by Eric Elliott

Programming JavaScript Applications by Eric Elliott

Author:Eric Elliott [Elliott, Eric]
Language: eng
Format: epub, pdf
Tags: Javascript, oreilly
ISBN: 9781491950241
Publisher: O’Reilly Media
Published: 0101-01-01T00:00:00+00:00


'<li class="' + guestClass + '" ' + 'id="' + guest.id +'">' + '<span class="name">' + guest.name + '</span></li>'

After:

<li class="<%= guestClass %>" id="<%= id %>"> <span class="name"><%= name %></span> </li>

Even better, now that it isn’t expressed in a JavaScript string, it’s obvious that it doesn’t belong in the JavaScript view layer at all. For a template this small, it wouldn’t do any harm to simply embed it in the HTML for the page. You can do that using a <script> tag:

<script id="guest" type="text/template"> <li class="<%= guestClass %>" id="<%= id %>"> <span class="name"><%= name %></span> </li> </script>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.