We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
textarea
select
Input element works correctly, probably because its value doesn't depend on other DOM nodes.
Input
The solution I found is to set each textarea value as its contents before cloning. For select it's similar, just with the 'selected' attribute.
function cloneContents(container) { // Preserve textarea values var textarea = findAll(container, "textarea"); textarea.text(function(i, text){return textarea[i].value}); // Preserve select values findAll(container, "select").each(function(i, elem){ elem = $(elem); var values = $(elem).val(); elem.find('option[selected]').attr('selected', false); elem.find('option').filter(function(){ return ($.inArray(this.value, values) !== -1); }).attr('selected', true); }); var cloned = container.clone() //...
The text was updated successfully, but these errors were encountered:
👍 thanks for the answer. This should be documented more in the README. That some elements' states are not preserved such as <select>.
<select>
It would be better if have an out of the box solution as this behavior is expected to just work.
Sorry, something went wrong.
+1
Fixed issue defunkt#518: Textarea and select value isn't preserved wh…
dc4ab30
…en going back/forward
No branches or pull requests
textarea
and/orselect
elementInput
element works correctly, probably because its value doesn't depend on other DOM nodes.The solution I found is to set each
textarea
value as its contents before cloning.For
select
it's similar, just with the 'selected' attribute.The text was updated successfully, but these errors were encountered: