简体   繁体   English

Selectize.js 根本不起作用

[英]Selectize.js not working at all

For some reason I am not able to get Selectize.js working on my project at all.出于某种原因,我根本无法让 Selectize.js 在我的项目中工作。 I have checked all the jQuery links and they seem to be fine, but when I view the page all I get is a simple HTML drop down menu.我已经检查了所有 jQuery 链接,它们似乎都很好,但是当我查看页面时,我得到的只是一个简单的 HTML 下拉菜单。 I can't type directly into the box and there is no option to auto complete or add a new entry as at http://selectize.github.io/selectize.js/ (Single Item Select sub heading)我无法直接在框中键入,并且没有选项可以自动完成或添加新条目,如http://selectize.github.io/selectize.js/ (单项选择子标题)

I have tried to copy the simplest example from the Selectize site but even that doesn't work.我试图从 Selectize 站点复制最简单的示例,但即使这样也不起作用。 I can get a simple 'alert' pop up box to work so I know that jQuery is working.我可以得到一个简单的“警报”弹出框来工作,所以我知道 jQuery 正在工作。 The file address selectize/selectize.min.js is also correct.文件地址selectize/selectize.min.js也是正确的。

I would appreciate any help.我将不胜感激任何帮助。

HTML: HTML:

<!DOCTYPE html>
<html>
<head>


    <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700">
    <link rel="stylesheet" href="selectize/normalize.css">
    <link rel="stylesheet" href="selectize/styles.css">
    <link rel="stylesheet" href="selectize/default.css" data-theme="default">

    <!--[if IE 8]><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.0.8/es5-shim.min.js"></script><![endif]-->
    <script type="text/javascript" src="selectize/jquery-3.2.1.min.js"></script>

    <script type="text/javascript" src="selectize/selectize.min.js"></script>
    <script type="text/javascript" src="selectize/myjquery.js"></script>

</head>

<body>

<section class="demo" id="demo-single-item-select">
                <div class="header">
                    Single Item Select
                </div>
                <div class="sandbox">
                    <label for="select-beast">Beast:</label>
                    <select id="select-beast" class="demo-default" placeholder="Select a person...">
                        <option value="">Select a person...</option>
                        <option value="1">Chuck Testa</option>
                        <option value="4">Sage Cattabriga-Alosa</option>
                        <option value="3">Nikola Tesla</option>
                    </select>
                </div>

        <div class="description">
                    The most vanilla of examples.
                </div>

</section>


</body>
</html>

myjQuery:我的jQuery:

$(document).ready(function() {

   //alert('Ahoy hoy');
   $('#select-beast').selectize({
                    create: true,
                    sortField: 'text',
                    searchField: 'item',
                    create: function(input) {
                        return {
                            value: input,
                            text: input
                    }
}
                });


   });
<option value="">Select a person...</option>

删除 value 属性或给它任何名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM