﻿///<reference path="libs/require.js" />
///<reference path="libs/jquery.js" />
///<reference path="combo-box-item.js" />

define(['combo-box-item', 'libs/jquery'], function (ComboBoxItem) {
    var controls = (function () {
        function ComboBox(collection) {
            this._items = collection || [];
            this._collapsed = true;
        }

        ComboBox.prototype.render = function (htmlTemplate) {
            var self = this;
            var $combo = $('<div>')
                .addClass('combo-box')
            $('body').on('click', '.person-item', function () {
                var $this = $(this);
                if (!self._collapsed) {
                    self._collapsed = true;
                    $this.parent().find('.person-item').hide();
                    $this.show();
                } else {
                    $this.parent().find('.person-item').show();
                    self._collapsed = false;
                }
            });
            $('<div>')
                .addClass('list')
                .appendTo($combo);
            for (var i = 0; i < this._items.length; i++) {
                $combo.html($combo.html() + ComboBoxItem(this._items[i]).render(htmlTemplate));
                $combo.find('.person-item').hide().first().show();
            }
            return $combo.html();
        };

        return {
            ComboBox: function (collection) { return new ComboBox(collection); }
        };
    }());

    return controls;
});

@@ -480,47 +480,8 @@
 %3E')%0A
-                .addClass('combo-box')%0A
     
@@ -511,16 +511,27 @@
 lick', '
+#combo-box 
 .person-
@@ -547,28 +547,24 @@
 nction () %7B%0A
-    
             
@@ -950,87 +950,8 @@
     
-$('%3Cdiv%3E')%0A                .addClass('list')%0A                .appendTo($combo);
 %0A   
@@ -1199,21 +1199,106 @@
     
-return $combo
+var $list = $('%3Cdiv%3E').append($('%3Cdiv id=%22combo-box%22%3E').append($combo));%0A%0A            return $list
 .htm

fix controls.js