简体   繁体   English

Select2多个框没有响应

[英]Select2 multiple boxes not responding

I have a laravel 5.4 project and I am trying to get the Select2 boxes working. 我有一个laravel 5.4项目,我正在尝试使Select2框正常工作。 The problem is that the are not picking up the select2.min.js file and the select2.min.css in the public folder. 问题在于不会在公用文件夹中获取select2.min.js文件和select2.min.css。 This is what it looks like. 这就是它的样子。 For whatever reason I can't seem to reference the select2 files. 无论出于什么原因,我似乎都无法引用select2文件。

在此处输入图片说明

I have been wrestling with this for a couple of days. 我已经为此努力了几天。 I am trying to get this function to load 我正在尝试加载此功能

<script type="text/javascript">
    $('.select2-multi').select2();
</script>`

I have tried putting it in the body but no success. 我尝试将其放入体内,但未成功。 Below is my HTML: 以下是我的HTML:

    {{ Form::label('tags', 'Tags:') }}
    <select class="form-control select2-multi" name="tags[]" multiple="multiple">
        @foreach($tags as $tag)
            <option value='{{ $tag->id }}'>{{ $tag->name }}</option>
        @endforeach
    </select>
    {{ Form::label('featured_img', 'Upload a Featured Image') }}
    {{ Form::file('featured_img') }}
    {{ Form::label('body', "Post Body:") }}
    {{ Form::textarea('body', null, array('class' => 'form-control')) }}
    {{ Form::submit('Create Post', array('class' => 'btn btn-success btn-lg btn-block', 'style' => 'margin-top: 20px;')) }}
{!! Form::close() !!}

And my javascript: 而我的javascript:

{!! Html::script('js/parsley.min.js') !!}
{!! Html::script('js/select2.min.js') !!}

<script type="text/javascript">
    $('.select2-multi').select2();
</script>

why don't you put it directly in HTML instead of include section. 为什么不直接将其放在HTML中而不是包含部分中。

Please try this link from JSbin: http://jsbin.com/huropeqora/edit?html,output 请尝试使用JSbin中的以下链接: http ://jsbin.com/huropeqora/edit?html,输出

 $('.select2-multi').select2();

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

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