jquery-simple-combobox icon indicating copy to clipboard operation
jquery-simple-combobox copied to clipboard

How to pass invalid value with other form data

Open chilek opened this issue 6 years ago • 2 comments

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.

chilek avatar Sep 07 '18 00:09 chilek

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?

chilek avatar Sep 07 '18 08:09 chilek

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');

chilek avatar Sep 07 '18 09:09 chilek