add select2 with ajax for getting folders

This commit is contained in:
Uwe Steinmann 2024-10-31 18:10:28 +01:00
parent a7342b600e
commit 7bf9768359
2 changed files with 60 additions and 8 deletions

View File

@ -94,11 +94,37 @@ function initMost() { /* {{{ */
$(ev.currentTarget).datepicker('hide');
});
$(".chzn-select").select2({
$(".chzn-select").select2({ /* {{{ */
width: '100%',
templateResult: chzn_template_func//,
//templateSelection: chzn_template_func
});
templateResult: chzn_template_func
}); /* }}} */
$(".chzn-select-folder").select2({ /* {{{ */
theme: "bootstrap4",
width: 'resolve',
debug: false,
ajax: {
url: seeddms_webroot+"op/op.Ajax.php",
delay: 500,
data: function (params) {
var query = {
query: params.term,
command: 'searchfolder',
format: 'select2'
}
// Query parameters will be ?search=[term]&command=folderlist
return query;
},
processResults: function(data) {
$.map(data.results, function (obj) {obj.text = obj.name || obj.text; obj.subtitle = obj.path || obj.subtitle; return obj; });
return {
results: data.results
};
},
dataType: 'json'
},
templateResult: chzn_template_func
}); /* }}} */
/* change the color and length of the bar graph showing the password
* strength on each change to the passwod field.

View File

@ -96,12 +96,38 @@ function initMost() { /* {{{ */
});
*/
$(".chzn-select").select2({
$(".chzn-select").select2({ /* {{{ */
theme: "bootstrap4",
width: 'resolve',
templateResult: chzn_template_func//,
//templateSelection: chzn_template_func
});
debug: false,
templateResult: chzn_template_func
}); /* }}} */
$(".chzn-select-folder").select2({ /* {{{ */
theme: "bootstrap4",
width: 'resolve',
ajax: {
url: seeddms_webroot+"op/op.Ajax.php",
delay: 500,
data: function (params) {
var query = {
query: params.term,
command: 'searchfolder',
format: 'select2'
}
// Query parameters will be ?search=[term]&command=folderlist
return query;
},
processResults: function(data) {
$.map(data.results, function (obj) {obj.text = obj.name || obj.text; obj.subtitle = obj.path || obj.subtitle; return obj; });
return {
results: data.results
};
},
dataType: 'json'
},
templateResult: chzn_template_func
}); /* }}} */
/* change the color and length of the bar graph showing the password
* strength on each change to the passwod field.