JQuery Mobile:格式化自动完成结果

JQuery Mobile:格式化自动完成结果,jquery,jquery-mobile,Jquery,Jquery Mobile,我正在为一个内部web应用程序开发一个移动选项。我在PC端有一个自动选择功能,但在移动端查看时,搜索结果在显示时看起来很糟糕: 我希望列表视图看起来更像一个下拉列表。当显示在手机上时,我知道它可能会列在键盘下方,但现在还可以 我在我的主站点和移动站点上都使用了相同的代码片段。为了确定它是否是移动设备,我调用了一个函数:check_mobile 我在某处找到了autoselect代码,但不确定如何将格式应用于结果集。感谢您的帮助 html: jquery自动选择函数: init: functio

我正在为一个内部web应用程序开发一个移动选项。我在PC端有一个自动选择功能,但在移动端查看时,搜索结果在显示时看起来很糟糕:

我希望列表视图看起来更像一个下拉列表。当显示在手机上时,我知道它可能会列在键盘下方,但现在还可以

我在我的主站点和移动站点上都使用了相同的代码片段。为了确定它是否是移动设备,我调用了一个函数:check_mobile

我在某处找到了autoselect代码,但不确定如何将格式应用于结果集。感谢您的帮助

html:

jquery自动选择函数:

init: function(){
    $('#results').hide();
    $( "#Customer" ).val('');
    $( "#Customer" )
        // don't navigate away from the field on tab when selecting an item
        .bind( "keydown", function( event ) {
            if ( event.keyCode === $.ui.keyCode.TAB &&
                    $( this ).data( "autocomplete" ).menu.active ) {
                event.preventDefault();
            }
        })
        .autocomplete({
            delay: 500,
            source: function( request, add ) {
                $.getJSON( cust.url+"?funct=1" , {term: cust.extractLast( request.term )}, function(data) {  
                    //create array for response objects  
                    var suggestions = [];  
                    //process response
                   for(var i =1, ii=data[0];i<=ii;i++){
                        suggestions.push(data[i].ABAN8 + ':' + $.trim(data[i].ABDC));
                    }  
                    //pass array to callback  
                    add(suggestions);
                });
            },
            search: function() {
                // custom minLength
                $( "#custData" ).hide();
                $('#results').hide();
                var term = cust.extractLast( this.value );
                if ( term.length < 2 ) {
                    cust.clearReportData();
                    return false;
                }
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function( event, ui ) {
                var terms = cust.split( this.value );
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push( ui.item.value );
                // add placeholder to get the comma-and-space at the end
                terms.push( "" );
                cust.getfulldetail(ui.item.value);
                return false;
            }
        })
        .focus();
},

JQM有许多自动完成解决方案,您需要签出或。

JQM有许多自动完成解决方案,您需要签出或。

这里的具体问题是您忘记将css文件添加到您的解决方案中,例如,排序问题

  <link rel="stylesheet" type="text/css" href="css/jquery-ui-1.9.2.custom.css" />

这里的具体问题是,您忘记将css文件添加到解决方案中,例如,排序问题

  <link rel="stylesheet" type="text/css" href="css/jquery-ui-1.9.2.custom.css" />

使用如何?这是一个AJAX选项。它会在用户键入时搜索远程数据库关于如何使用?这是一个AJAX选择。它按用户类型搜索远程数据库我正在查找JQM自动完成搜索结果应显示在div上方,而不是按下div。您能帮忙吗我正在查找JQM自动完成搜索结果应显示在div上方,而不是按下div。您能帮忙吗