Skip to content

Commit f27b6cb

Browse files
author
Alexander.L
committed
src/Form/Field/Select.php fix let elm
1 parent 5037ac8 commit f27b6cb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Form/Field/Select.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,12 @@ public function ajax($url, $idField = 'id', $textField = 'text')
227227
'placeholder' => $this->label,
228228
], $this->config);
229229

230+
$element_id = str_replace('.', '', $this->getElementClassSelector());
231+
230232
$this->additional_script = <<<JS
231-
let elm = document.querySelector("{$this->getElementClassSelector()}");
233+
let elm_{$element_id} = document.querySelector("{$this->getElementClassSelector()}");
232234
var lookupTimeout;
233-
elm.addEventListener('search', function(event) {
235+
elm_{$element_id}.addEventListener('search', function(event) {
234236
clearTimeout(lookupTimeout);
235237
lookupTimeout = setTimeout(function(){
236238
var query = {$this->choicesObjName()}.input.value;
@@ -240,7 +242,7 @@ public function ajax($url, $idField = 'id', $textField = 'text')
240242
}, 250);
241243
});
242244
243-
elm.addEventListener('choice', function(event) {
245+
elm_{$element_id}.addEventListener('choice', function(event) {
244246
{$this->choicesObjName()}.setChoices([], '{$idField}', '{$textField}', true);
245247
});
246248
JS;

0 commit comments

Comments
 (0)