0

我从我input-combobox的问题outocomplete中获取数据json是我想在打开时显示所有数据combobox(当单击按钮时),我需要initialValues在我的函数中定义,但我不知道如何。

编码:

        $(document).ready(function () {
                $("#auto").combobox({
                    initialValues: {//here I don't know what to write
                    },
                    source: function (request, response) {
                        $.getJSON('http://<%=HttpContext.Current.Items["ip"].ToString()%>/JSON/Auctocomplete.aspx?city=1' + "&term=" + request.term, function (data) { response(data); });
                    }
                });
            });

$.widget("ui.combobox", {
        _create: function () {
            var _self = this
                , options = $.extend({}, this.options, {
                    minLength: 0,
                    source: function (request, response) {
                        if (!request.term.length) {
                            response(_self.options.initialValues);
                        } else {
                            if (typeof _self.options.source === "function") {
                                _self.options.source(request, response);
                            } else if (typeof _self.options.source === "string") {
                                $.ajax({
                                    url: _self.options.source,
                                    data: request,
                                    dataType: "json",
                                    success: function (data, status) {
                                        response(data);
                                    },
                                    error: function () {
                                        response([]);
                                    }
                                });
                            }
                        }
                    }
                });

            this.element.autocomplete(options);

            this.button = $("<button type='button'>&nbsp;</button>")
                .attr("tabIndex", -1)
                .attr("title", "הראה את כל הערים")
                .insertAfter(this.element)
                .button({
                    icons: {
                        primary: "ui-icon-triangle-1-s"
                    },
                    text: false
                })
                .removeClass("ui-corner-all")
                .addClass("ui-corner-right ui-button-icon")
                .click(function () {
                    if (_self.element.autocomplete("widget").is(":visible")) {
                        _self.element.autocomplete("close");
                        return;
                    }
                    _self.element.autocomplete("search", "");
                    _self.element.focus();
                });
        }
    });
4

0 回答 0