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

javascript - Chosen jQuery plugin not functional. - Stack Overflow

programmeradmin2浏览0评论

Using Chosen version 1.0.0 I included the following files

link(href='css/chosen.css', rel="stylesheet", type="text/css");
script(src='js/chosen.jquery.min.js')
script.
    $(".chosen-select").chosen()

body
  select(data-placeholder="Choose a country...", multiple style="width:350px;" ).chosen-select
            <option value=""></option>
            <option value="United States">United States</option>
            <option value="United Kingdom">United Kingdom</option>
            <option value="Afghanistan">Afghanistan</option>
            <option value="Aland Islands">Aland Islands</option>
            <option value="Albania">Albania</option>
            <option value="Algeria">Algeria</option>
            <option value="American Samoa">American Samoa</option>

The above code gives a disfunctional select box The above display is same as

select(multiple, style="width:350px;")
            <option value=""></option>
            <option value="United States">United States</option>

Upon analysis I see, that both chosen.css and chosen.jquery.min.js have no class chosen-select I am using jQuery version v1.10.2 Also I am loading jQuery as the first file on the page to avoid conflict.

Thanks for helping.

Using Chosen version 1.0.0 I included the following files

link(href='css/chosen.css', rel="stylesheet", type="text/css");
script(src='js/chosen.jquery.min.js')
script.
    $(".chosen-select").chosen()

body
  select(data-placeholder="Choose a country...", multiple style="width:350px;" ).chosen-select
            <option value=""></option>
            <option value="United States">United States</option>
            <option value="United Kingdom">United Kingdom</option>
            <option value="Afghanistan">Afghanistan</option>
            <option value="Aland Islands">Aland Islands</option>
            <option value="Albania">Albania</option>
            <option value="Algeria">Algeria</option>
            <option value="American Samoa">American Samoa</option>

The above code gives a disfunctional select box The above display is same as

select(multiple, style="width:350px;")
            <option value=""></option>
            <option value="United States">United States</option>

Upon analysis I see, that both chosen.css and chosen.jquery.min.js have no class chosen-select I am using jQuery version v1.10.2 Also I am loading jQuery as the first file on the page to avoid conflict.

Thanks for helping.

Share Improve this question asked Sep 2, 2013 at 8:33 Sangram SinghSangram Singh 7,19115 gold badges51 silver badges79 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

Adding

script.
        $(document).ready(function(){
            $(".chosen-select").chosen()
        });

Instead of just $(".chosen-select").chosen() makes it work!

Mine doesn't worked instead it worked by

<script type="text/javascript" src="js/chosen.jquery.js" >
</script>   
<script>
    `Enter only enter chosen related code here`
</script>

This can sometimes happened because the confliction of the jquery library. Define your JavaScript inside no conflict. https://api.jquery./jquery.noconflict/

发布评论

评论列表(0)

  1. 暂无评论