Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass invalid value with other form data #91

Open
chilek opened this issue Sep 7, 2018 · 2 comments
Open

How to pass invalid value with other form data #91

chilek opened this issue Sep 7, 2018 · 2 comments

Comments

@chilek
Copy link

chilek commented Sep 7, 2018

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
Copy link
Author

chilek commented Sep 7, 2018

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
Copy link
Author

chilek commented Sep 7, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant