mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-59867 autocomplete: Prevent duplicate ids.
Rendering a form with 2 autocompletes in it can get messed up because of duplicated ids.
This commit is contained in:
parent
b3cfb01316
commit
b7df2485e6
2
lib/amd/build/form-autocomplete.min.js
vendored
2
lib/amd/build/form-autocomplete.min.js
vendored
File diff suppressed because one or more lines are too long
@ -37,6 +37,8 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
UP: 38
|
||||
};
|
||||
|
||||
var uniqueId = $.now();
|
||||
|
||||
/**
|
||||
* Make an item in the selection list "active".
|
||||
*
|
||||
@ -786,11 +788,15 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
// Find or generate some ids.
|
||||
var state = {
|
||||
selectId: originalSelect.attr('id'),
|
||||
inputId: 'form_autocomplete_input-' + $.now(),
|
||||
suggestionsId: 'form_autocomplete_suggestions-' + $.now(),
|
||||
selectionId: 'form_autocomplete_selection-' + $.now(),
|
||||
downArrowId: 'form_autocomplete_downarrow-' + $.now()
|
||||
inputId: 'form_autocomplete_input-' + uniqueId,
|
||||
suggestionsId: 'form_autocomplete_suggestions-' + uniqueId,
|
||||
selectionId: 'form_autocomplete_selection-' + uniqueId,
|
||||
downArrowId: 'form_autocomplete_downarrow-' + uniqueId
|
||||
};
|
||||
|
||||
// Increment the unique counter so we don't get duplicates ever.
|
||||
uniqueId++;
|
||||
|
||||
options.multiple = originalSelect.attr('multiple');
|
||||
|
||||
if (typeof closeSuggestionsOnSelect !== "undefined") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user