You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any idea how to set already selected options, if my form at submit has errors, and the framework redirects back to the form with error messages.
I tried adding this as parameter but nothing selected:
This is a realy not intuitive thing. Usually you need 2 fields for the process. 1st field with saved values comma separated i.e. in a database on the server, 2nd is the multi select field itself. For automation I'm using a naming convention for the multi select field: id of field i.e. = name -> id of multi select field = name + 'Ms'.
For init of all selected values and all multi select fields on a page I use this function...
(function initMultiSelects() {
// select all multi select objects
var data = $('.msCheckboxDeliver');
$.each(data, function(key, msObj) {
// set datas only if object has an id and datas are there
if (msObj.id != '' && msObj.value) {
// get the comma separated values as array
var dataArr = msObj.value.split(',');
// set select2 datas
$('#' + msObj.id + 'Ms').data('select2').data(dataArr);
// check options of select2MultiCheckboxes
$.each(dataArr, function(key, value) {
// set values
var obj = $('#' + msObj.id + 'Ms option[value=' + value + ']');
// set option class checked
obj.addClass('checked');
});
}
});
})();
Any idea how to set already selected options, if my form at submit has errors, and the framework redirects back to the form with error messages.
I tried adding this as parameter but nothing selected:
The text was updated successfully, but these errors were encountered: