Fix select2 library dependency checks

- Added safety checks for select2 library availability
- Prevents TypeError when select2 library not loaded
- Falls back to regular input behavior when select2 unavailable
- Fixed getSeparator function to handle missing select2 defaults
This commit is contained in:
Micha
2025-07-28 12:54:17 +02:00
parent 9d84a1f21d
commit dda7550181
6 changed files with 104 additions and 329 deletions

View File

@@ -71,29 +71,29 @@ $(function() {
});
// Note: This would require select2 library to be loaded
// $('#select2-test').editable({
// type: 'select2',
// url: 'demo/demo.php',
// source: [
// {id: 'us', text: 'United States'},
// {id: 'gb', text: 'Great Britain'},
// {id: 'ru', text: 'Russia'},
// {id: 'de', text: 'Germany'},
// {id: 'fr', text: 'France'},
// {id: 'es', text: 'Spain'},
// {id: 'it', text: 'Italy'}
// ],
// value: 'us',
// select2: {
// placeholder: 'Select Country',
// allowClear: true
// },
// success: function(response, newValue) {
// console.log('Select2 success:', newValue);
// },
// error: function(response) {
// console.log('Select2 error:', response);
// }
// });
$('#select2-test').editable({
type: 'select2',
url: 'demo/demo.php',
source: [
{id: 'us', text: 'United States'},
{id: 'gb', text: 'Great Britain'},
{id: 'ru', text: 'Russia'},
{id: 'de', text: 'Germany'},
{id: 'fr', text: 'France'},
{id: 'es', text: 'Spain'},
{id: 'it', text: 'Italy'}
],
value: 'us',
select2: {
placeholder: 'Select Country',
allowClear: true
},
success: function(response, newValue) {
console.log('Select2 success:', newValue);
},
error: function(response) {
console.log('Select2 error:', response);
}
});
})