最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - select2 search box dropdown not working - Stack Overflow

programmeradmin1浏览0评论

Select2 problem,

I do not want drop down search box, i want to make first line in search,

How can i do?

How do I search by location placeholder? CODE :

<select name="search" class="box"></select>

Example pictures,

$(".box").select2({
    minimumInputLength: 2,          
    placeholder: ' Search!',
  cache:true,
     ajax: {
        dataType: 'json',
        url: 'ajax.php',
        delay: 400,
        data: function(params) {
            return {
                term: params.term
            }
        },
        processResults: function (data, page) {
          return {
            results: data.results
          };
        }
    }
});

Thanks..

Select2 problem,

I do not want drop down search box, i want to make first line in search,

How can i do?

How do I search by location placeholder? CODE :

<select name="search" class="box"></select>

Example pictures,

$(".box").select2({
    minimumInputLength: 2,          
    placeholder: ' Search!',
  cache:true,
     ajax: {
        dataType: 'json',
        url: 'ajax.php',
        delay: 400,
        data: function(params) {
            return {
                term: params.term
            }
        },
        processResults: function (data, page) {
          return {
            results: data.results
          };
        }
    }
});

Thanks..

Share Improve this question edited Dec 11, 2015 at 8:47 Gokul P P 9629 silver badges29 bronze badges asked Dec 11, 2015 at 8:13 umutumut 131 gold badge1 silver badge9 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 0

Add the following to your CSS, make sure that it appears below the CSS for select2:

.select2-drop-active{
    margin-top: -25px;
}

Here is a demo jsFiddle

Note that this will effect all of your select2 elements. To target specific elements, simply adjust the selector for the rule to suit your needs.

enter image description here $("select#currency(class or id name)").select2({ tags : true, createTag : function(params) { return undefined; } });

发布评论

评论列表(0)

  1. 暂无评论