jquery-pjax icon indicating copy to clipboard operation
jquery-pjax copied to clipboard

Fixed issue #518: Textarea and select value isn't preserved

Open the-ress opened this issue 9 years ago • 5 comments

Fixed issue #518: Textarea and select value isn't preserved when going back/forward

the-ress avatar Jul 10 '15 23:07 the-ress

Hi thanks for the contribution. This would need automated tests in order to be accepted. The tests should also verify whether regular <input> fields have their values preserved (I assume they have by default?).

Does this handle <select> boxes with multiple values? Also, could this adversely affect our caching functionality somehow?

mislav avatar Jul 17 '15 21:07 mislav

Given this PR is already a few months old, I have decided to jump in and help with the tests, see https://github.com/masone/jquery-pjax/commit/f9c06149f6058a1fd440d3e885c4d225a9e58e29. I can confirm that <textarea> and <select> do not preserve their values, but other form elements do. There are now 5 failing tests on my branch.

When testing @the-ress' changes, the one for the single <select> is still failing. I'm not sure wether your code or my tests need additional work, it would be nice to have a second pair of eyes on it. Please note that the assertions for the multi are slightly different from the single which might lead to one test failing while the other works.

I'm new to jquery-pjax, so please have a thorough look before merging my changes.

masone avatar Sep 23 '15 17:09 masone

Thank you for the tests. I never managed to set up the environment to be able to run them.

The single value select was a bug in the original PR. I fixed it and merged your test branch.

the-ress avatar Sep 23 '15 18:09 the-ress

@the-ress I'm sorry you had problems running the test suite locally. You need to have Ruby with Bundler installed and run script/bootstrap. Then, you can run script/server -p 3000 (or another port of your choise) and open http://localhost:3000 in your browser.

mislav avatar Sep 23 '15 18:09 mislav

Ugh sorry, I messed up the git history on the temporary form_tests_theress branch. I thought you would merge the form_tests instead. Please squash the commits before you finish this PR :see_no_evil: :smile:

masone avatar Sep 24 '15 08:09 masone