pdownButton.jqxDropDownButton('close');
                        } else {
                            $dropdownButton.find(".dropdown-button-icon").addClass("is-open");
                            $dropdownButton.jqxDropDownButton('open');
                        }
                    }),
                    dropdownWidth = 0, dropdownHeight = 0, iconWidth = 0, iconHeight = 0, cssClasses = "",
                    backgroundSize = "", iconSize = viewModel.iconSize(),
                    buttonType = viewModel.type, buttonStyle = viewModel.style, isOpen = viewModel.isOpen();

                if (iconSize === "mini") {
                    iconWidth = 16;
                    iconHeight = 16;
                    backgroundSize = "16px 16px";
                    dropdownWidth = 22;
                    dropdownHeight = 22;
                } else {
                    iconWidth = 24;
                    iconHeight = 24;
                    backgroundSize = "24px 24px";
                    dropdownWidth = 32;
                    dropdownHeight = 30;
                }

                if (isOpen) {
                    cssClasses = " is-open";
                }

                // Knockout templates can not be loaded into the dropdown via
                // the usual HTML ko tags. This works just as well.
                ko.renderTemplate(
                    viewModel.dropdownContent().template(),
                    dropdownBindingContext, {},
                    $tempDiv,
                    'replaceNode');

                $dropdownButton.jqxDropDownButton({
                    width: dropdownWidth,
                    height: dropdownHeight,
                    animationType: 'none',
                    theme: 'dropdownButton'
                });

                // Icons need to be fixed for all the buttons:
                $dropdownButton.jqxDropDownButton(
                    'setContent',
                    '<div class="dropdown-button-icon dropdown-button-' + viewModel.style + cssClasses + '" style="width: ' + iconWidth + 'px; height: ' + iconHeight +
                        'px; background-size: ' + backgroundSize + ';" />');
                $dropdownButton.find(".jqx-dropdownlist-content").width(dropdownWidth);
                $dropdownButton.find(".jqx-dropdownlist-content").height(dropdownHeight);

                ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
                    isOpenSubscription.dispose();
                    $dropdownButton.jqxDropDownButton('close');
                    $dropdownButton.jqxDropDownButton('destroy');

                });

                $dropdownButton.on('open', function (event) {
                    viewModel.isOpen(true);
                });

                $dropdownButton.on('close', function (event) {
                    viewModel.isOpen(false);
                });

            }
        };

    });