laravel - select2 远程搜索在liverwire 中不起作用
问题描述
我正在使用 livewire 和 select2。我有 select2 选项来选择客户。
livewire 刀片是一个引导模式。在模式中有一个 select2 选项来选择客户。
客户正在使用 ajax 功能进行搜索。问题是 ajax 函数在模态中不起作用。
模态如下
<script>
$(document).ready(function () {
$("#customer_select").select2({
dropdownParent: '#customerReviewModalId',
ajax: {
url: "{{ route('customers.search-customers') }}",
dataType: 'json',
delay: 250,
data: function (params) {
x = {
filter_string: params.term,
filter_column: ['first_name', 'email']
};
return x;
},
processResults: function (data, params) {
params.page = params.page || 1;
return {
results: data,
pagination: {
more: (params.page * 30) < data.length
}
};
},
cache: true
},
placeholder: 'Search Customer',
theme: "bootstrap",
escapeMarkup: function (markup) {
return markup;
},
minimumInputLength: 3,
// templateResult: formatAirport,
// templateSelection: formatAirportSelection
});
});
</script>
<div class="modal fade" id="customerReviewModalId" role="dialog" aria-labelledby="modelTitleId">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Your Reviews</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form enctype="multipart/form-data" wire:submit.prevent="submit">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="customer_select">Customer</label>
<select class="form-control" id="customer_select">
<option value=""></option>
</select>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<label for="reviewTitle">Title</label>
<input type="text" class="form-control" wire:model="title"
aria-describedby="titlehelpId">
<small id="helpId" class="form-text text-muted">Your Review Title Add Here</small>
</div>
<div class="form-group" wire:ignore>
<label for="reviewTitle">Image</label>
<input type="file" class="form-control dropify" wire:model="image"
aria-describedby="imagehelpId" data-max-file-size="2M" accept="image/*">
<small id="imagehelpId" class="form-text text-muted">Add Your Review Image Here</small>
</div>
<div class="form-group">
<label for="reviewTitle">Review</label>
<textarea class="form-control" wire:model="review" rows="10"
aria-describedby="reviewhelpId"></textarea>
<small id="reviewhelpId" class="form-text text-muted">Add Your Review Here</small>
<input type="hidden" wire:model="product_id">
</div>
<div class="form-group">
<label for="">Rating</label>
<select class="form-control" wire:model="ratings">
<option value="5">5 Stars</option>
<option value="4">4 Stars</option>
<option value="3">3 Stars</option>
<option value="2">2 Stars</option>
<option value="1">1 Stars</option>
</select>
</div>
</div>
<div class="col-lg-4">
<button type="submit" class="btn btn-info">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
没有任何控制台错误
解决方案
推荐阅读
- python - GMS 3.4.x 中的 Python - 使用 matplotlib.pyplot 时 DM 崩溃:无法找到或加载 Windows 的 Qt 平台插件
- c++ - 从函数返回对内部的 unique_ptr 后出现分段错误
- javascript - 在 Jquery 中使用 contenteditable 处理复制/粘贴和最大长度
- php - 将帖子 ID 附加到 html“Like”按钮并通过 jQuery 获取它如何安全?
- angular - 如何在不使用 TestBeds 的情况下模拟 FormGroup 的 get 方法?
- javafx - 如何使用 JGit 在 JavaFX 中绘制提交历史
- python-3.x - 使用 azure VM 在 SOA 中编排服务
- android - React-native 构建失败:“无法创建任务 ':app:copyDownloadableDepsToLibs'”
- php - 2Checkout Resource Not Found 错误 (RESTAPI 5.0)
- node.js - axios+node.js+cors : 甚至 OPTIONS 请求也无法到达服务器