zoukankan      html  css  js  c++  java
  • jQuery.autoComplete 多参数

    query 版本 1.3.2
    插件默认的 参数 是q 如果需要传递多个参数呢?
    $("#stylistname").autocomplete("/page/autostylistname.php", { 
    minChars: 0, 
    extraParams: {shopid:function(){return $('#shopid').val();}}, 
     170, 
    selectFirst: false, 
    dataType: "json", 
    formatResult: function(data) { return data.name; }, 
    parse: function(data) { return $.map(data, function(row) { return { data: row, value: row.name, result: row.name } }); }, 
    formatItem: function(item) { if(item.jobnumber.indexOf('号')>-1){ return item.name+' '+item.jobnumber; } return item.name+' '+item.jobnumber+'号'; } });

    红色部分即为需要的参数
    html页面
    <input id='shopid' value=''/>
    在php 页就可以 用 $_GET['shopid'] 获取了

    query-ui 版本 1.8.1以上

    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>jQuery UI Autocomplete - Remote JSONP datasource</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    <style>
    .ui-autocomplete-loading {
      background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
    }
    #city { 25em; }
    </style>
    <script>
    $(function() {
    function log( message ) {
      $( "<div>" ).text( message ).prependTo( "#log" );
      $( "#log" ).scrollTop( 0 );
    }
     
    $( "#city" ).autocomplete({
      source: function( request, response ) {
      $.ajax({
        url: "http://gd.geobytes.com/AutoCompleteCity",
        dataType: "jsonp",
        data: {
          q: request.term
        },
        success: function( data ) {
          response( data );
        }
      });
      },
      minLength: 3,
      select: function( event, ui ) {
        log( ui.item ?
        "Selected: " + ui.item.label :
        "Nothing selected, input was " + this.value);
      },
      open: function() {
        $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
      },
      close: function() {
        $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
      }
    });
    });
    </script>
    </head>
    <body>
     
    <div class="ui-widget">
    <label for="city">Your city: </label>
    <input id="city">
    Powered by <a href="http://geonames.org">geonames.org</a>
    </div>
     
    <div class="ui-widget" style="margin-top:2em; font-family:Arial">
    Result:
    <div id="log" style="height: 200px; 300px; overflow: auto;" class="ui-widget-content"></div>
    </div>
     
     
    </body>
    </html>
  • 相关阅读:
    callAfter 例子2
    wxpython
    python 处理excel 进程无法退出的问题
    常用电子技术网
    Emeditor 与正则表达式
    Windows程序中的字符编码
    Delphi7 无法启动 问题搞定
    2007中国发烧盘点之作《天路》发烧女声版
    一台电脑安装多个(虚拟)网卡问题
    无法删除xxx文档/文件夹:找不到指定的路径。请确定指定的路径是否正确
  • 原文地址:https://www.cnblogs.com/Alex80/p/5340745.html
Copyright © 2011-2022 走看看