为什么我的拾色器不工作,它不允许我拾取颜色,也没有错误?

Why my color picker is not working it is not allowing me to pick color and there is no error too?

提问人:Cookie 提问时间:11/2/2023 最后编辑:romeo1987Cookie 更新时间:11/3/2023 访问量:50

问:

    @extends('layouts.admin')
@section('title_page','Car Exterior Color')
@section('content')
<div class="card">

    <div class="card-body">
        @if (session('status'))
        <div class="alert alert-success" role="alert">
            {{ session('status') }}
        </div>
        @endif
        <div class="col-sm-12 text-right">
            <button type="button" data-toggle="modal" data-target="#createEditModal" class="btn btn-primary" id="add-btn">
                <i class="fas fa-plus"></i> Add New </button>
        </div>
        &nbsp;
        <table class="table table-bordered data-table">
            <thead class="thead-dark">
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Color Title(EN)</th>
                    <th scope="col"> Color Title(AR)</th>
                    <th scope="col">Color Code</th>
                    <th scope="col">Action</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

@include('cars.exterior_color.create_edit_modal')

@endsection

@section('additional_css')
<link href="https://cdn.datatables.net/1.11.4/css/dataTables.bootstrap5.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-colorpicker/3.2.0/css/bootstrap-colorpicker.min.css">
@endsection

@section('additional_js')
<script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.11.4/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-colorpicker/3.2.0/js/bootstrap-colorpicker.min.js"></script>
<script type="text/javascript">
    $(function() {
        App.Cars.ExteriorColors = {
            loadEditData(e) {
                var $url = $(e).attr('href');
                $.get($url, function($response) {
                    $('#createEditForm').trigger('reset');
                    $('#createEditModal').modal('show');
                    $('#exterior_color').val($response.resp.exterior_color);
                    $('#exterior_color_ar').val($response.resp.exterior_color_ar);
                    $('#color_code').val($response.resp.color_code);
                    $('#method').val("PUT");
                    $('#url').val($response.route);
                    $(".close").on("click", function() {
                        $("#createEditModal").modal('hide');
                    });
                    $("#close-btn").on("click", function() {
                        $("#createEditModal").modal('hide');
                    });
                })
            },

        }

        App.Cars.saveData('{{ route("cars.exteriorcolors.store")}}')
        App.Cars.resetData();
        var table = $('.data-table').DataTable({
            processing: true,
            serverSide: true,
            ajax: {
                url: "{{ route('cars.exteriorcolors.listing') }}",
                method: 'POST'
            },
            columns: [{
                    data: 'uid',
                    name: 'uid'
                },
                {
                    data: 'name',
                    name: 'name'
                },
                {
                    data: 'name_ar',
                    name: 'name_ar'
                },
                {
                    data: 'code',
                    name: 'code'
                },
                {
                    data: 'action',
                    name: 'action',
                    orderable: false,
                    searchable: false
                },
            ]
        });

    });
    $("#modulesForm").validate();
    var color = $("#color_code").val();
    $("#component-colorpicker").colorpicker({
        format: "hex",
        color: color,

    });
</script>
@endsection

为什么我无法从颜色选择器中选择颜色我已经正确地完成了所有事情 @include('cars.exterior_color.create_edit_modal')这有包含所有 ID 的模态,当我在单独的页面中执行此操作时,一些代码有效,但在此页面中不起作用,我包含了整个页面,因为也许有一些链接是冲突的,但我没有得到我出错的地方,并且应采取的措施

HTML jQuery CSS 颜色选择器

评论

0赞 brombeer 11/2/2023
您的颜色选择器元素究竟在哪里?在该代码中找不到任何带有 id 的元素component-colorpicker
0赞 Cookie 11/3/2023
它位于此处包含的模态中的其他文件中

答: 暂无答案