如何使用触发器等在文档就绪初始化我的函数..?

时间:2017-05-12 09:00:38

标签: javascript jquery autocomplete document-ready

当qololbl鼠标点击当时自动完成功能工作正常但如何在没有qololbl点击的情况下初始化文件准备就绪。

我试图把这个代码放在文件准备好的$(' .qololbl')。点击()那时点击功能工作但是自动完成功能不起作用所以如何初始化这个qololbl点击功能就准备就绪了

$(document).ready(function (e) {    

        $(".qololbl").click(function(){
                var garshunivalue = 0;          
                if($('#True').val() == "true")
                {               
                    if($('#defaultgarshuniid').val() > 0)
                    {
                        garshunivalue = $('#defaultgarshuniid').val();
                    }
                }
                $("#qoloname").autocomplete({
                    source: LiveUrl + "/api/Qolo/QoloList?garshunivalue="+garshunivalue,
                    select: function (event, ui) {                  
                        $("#qoloname").val(ui.item.Qolo_Name);                          

                       var searchtype1;
                       if(typeof $('input[name=radio-choice-t-6]:checked').val() == "undefined")
                       {
                           searchtype1 = 'qolo';
                       }
                       else
                       {
                           searchtype1 = $('input[name=radio-choice-t-6]:checked').val();
                       }
                        window.location.href = "index.html?term="+ui.item.Qolo_Name+ "&type=" + searchtype1;                
                    },

                    minLength: 0,
                    close: function(){
                        $(this).blur();
                    }}).focus(function(event, ui){
                        $(this).autocomplete("#stanza", "");
                    }); 

                $.ui.autocomplete.prototype._renderItem = function (ul, item) {

                    var re = new RegExp($.trim(this.term.toLowerCase()));
                    var qoloname = item.Qolo_Name.replace(re, "<span style='font-weight:600;color:#5C5C5C;'>" + $.trim(this.term.toLowerCase()) + "</span>");
                    var garshuniname = item.Garshuni_Name.replace(re, "<span style='font-weight:600;color:#5C5C5C;'>" + $.trim(this.term.toLowerCase()) + "</span>");
                        return $("<li></li>")
                            .data("item.autocomplete", item)
                            .append("<a>"+ "<div style='float:right;'>" + qoloname + "</div>" +"<div style='float:left;'>" + garshuniname + "</div>" + "</a>")
                            .appendTo(ul);
                };          
            });

            $('.qololbl').click();

    });

提前感谢。

帮帮我

0 个答案:

没有答案