         @render()
 
 
-    onNewGuest: ->
-        email = @$('input[name="guest-name"]').val()
+    # Handle guest addition. `userInfo` is passed when called by the typeahead.
+    onNewGuest: (userInfo = null) ->
+
+        if userInfo?
+            [email, contactID] = userInfo.split(';')
+        else
+            email = @$('input[name="guest-name"]').val()
+            contactID = null
+
         guests = @model.get('attendees') or []
         if not _.findWhere(guests, email: email)
             # Clone the source array, otherwise it's not considered as

            $guests.append row


    onRemoveGuest: (event) ->
        # Get which guest to remove.
        index = @$(event.target).parents('li').attr 'data-index'

                key: random.randomString()
                status: 'INVITATION-NOT-SENT'
                email: email
                contactid: contactID
            @model.set 'attendees', guests

            # Inefficient way to refresh the list, but it's okay since it will
            # never be a big list.
            @render()

        # Reset form field.
        @$('input[name="guest-name"]').val ''
        @$('input[name="guest-name"]').focus()


    onKeyup: (event) ->
