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:
48
demo/demo.js
48
demo/demo.js
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user