/vendor/encore/laravel-admin/src/Form/Field
下的Select.php
檔案
$script = <<<EOT
$(document).off('change', "{$this->getElementClassSelector()}");
$(document).on('change', "{$this->getElementClassSelector()}", function () {
var target = $(this).closest('.fields-group').find(".$class");
$.get("$sourceUrl",{q : this.value}, function (data) {
target.find("option").remove();
$(target).select2({
placeholder: $placeholder,
allowClear: $allowClear,
data: $.map(data, function (d) {
d.id = d.$idField;
d.text = d.$textField;
return d;
})
}).trigger('change');
});
});
$('{$this->getElementClassSelector()}').trigger('change');
EOT;
新增
$('{$this->getElementClassSelector()}').trigger('change');
本作品採用《CC 協議》,轉載必須註明作者和本文連結