jquery-simple-combobox
jquery-simple-combobox copied to clipboard
How to pass invalid value with other form data
Hello,
Thanks for great piece of code! is there a way to pass entered invalid value with other form data? I've found other solution so far - during form submit button handler I create additional hidden input with custom name attribute, but it's kind of dirty hack in my opinion.
Bests.
As workaround now I use the following code snippet:
$('#submit-button').click(function(e) {
var combobox = $('[name="config[section]"]').closest('.scombobox')
var section = combobox.scombobox('val');
$('<input type="hidden" name="config[section]" value="' + section + '">').insertAfter(combobox);
$('form[name="config"]').submit();
});
but it's not elegant and requires additional code to properly submit invalid value. Maybe it's possible to copy name attribute from original select element to scombobox-value class element? Or don't I know something?
My temporary workaround has evolved to:
$('.scombobox').scombobox('change', function (e) {
var scomboboxelem = $(this).closest('.scombobox');
var name = scomboboxelem.find('select').attr('name');
$(this).attr('name', name);
}, 'lms-ui');