Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
CoffeeScript Application Development

You're reading from   CoffeeScript Application Development What JavaScript user wouldn't want to be able to dramatically reduce application development time? This book will teach you the clean, elegant CoffeeScript language and show you how to build stunning applications.

Arrow left icon
Product type Paperback
Published in Aug 2013
Publisher Packt
ISBN-13 9781782162667
Length 258 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Ian Greenleaf Young Ian Greenleaf Young
Author Profile Icon Ian Greenleaf Young
Ian Greenleaf Young
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

CoffeeScript Application Development
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
1. Running a CoffeeScript Program FREE CHAPTER 2. Writing Your First Lines of CoffeeScript 3. Building a Simple Application 4. Improving Our Application 5. Classes in CoffeeScript 6. Refactoring with Classes 7. Advanced CoffeeScript Usage 8. Going Asynchronous 9. Debugging 10. Using CoffeeScript in More Places 11. CoffeeScript on the Server Index

Making an asynchronous request


Let's start building our new feature! We'll add some CSS to style our new page element:

#pet_information .more {
  color: gray;
}

#pet_information .more p {
  border: 1px solid #CCC;
  border-left: none;
  border-right: none;
  padding: 1em 0;
  margin-top: 2em;
}

#pet_information .more a {
  color: #194900;
}

We'll trigger a lookup from PetListView whenever a new pet is selected from the list:

selectPet: (petIndex, element) ->
  petView = @views[petIndex]
  @renderToElement "pet_information",
    petView.formattedDescription()
  petView.renderExtraContent()

We need to add a container element to the bottom of the content rendered by our PetView:

formattedDescription: ->
  "<h2>#{@pet.name}</h2>" +
    "<h3 class='breed'>#{@pet.breed} " +
    "(#{@pet.age ? "??"} years old)</h3>" +
    @imageTag(@pet.image) +
    "<p class='description'>#{@pet.description}</p>" +
    "<div id='additional_info' class='more'></div...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image