Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Select field loses value after resetting form #270

Closed
ghost opened this issue Jan 9, 2013 · 3 comments
Closed

Select field loses value after resetting form #270

ghost opened this issue Jan 9, 2013 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 9, 2013

In version 1.8.0+f reset button does not reset select field at all.
Correct behavior of browser on form reset would be to select first option in select field.

Tested this out on older version 1.7.5.
Tested browsers:

Chome, Firefox, Safari, Opera, IE8, IE9, IE10.

It works correctly in all browsers but in IE8 and IE9. In this two browsers after form reset select field is left blank like nothing is selected.

Corrected this by replacing:

spanTag.html($e.find(":selected").html());

with this:

var selected = $e.find("option:first");
spanTag.text(selected.text());

@fidian
Copy link
Collaborator

fidian commented Jan 9, 2013

Would you check out the develop branch? There's been so much work on there to fix bugs just like this. I'm planning on bundling it up and releasing it as "Version 2.0.0" once I get all of the tickets that are actual bugs resolved. If I recall correctly, the develop branch specifically fixes an issue with this.

@ghost
Copy link
Author

ghost commented Jan 9, 2013

Downloaded latest development version and tested demo.html

Chrome does not reset value at all.

Look at this simple example http://jsfiddle.net/LwsQa/ . If you select option 'third' and press reset button option 'first' will be selected. Uniform 1.8 or 2.0 does not bahave like this.

IE8 errors out when I click on select:

Message: 'console' is undefined
Line: 72
Char: 3
Code: 0
URI: file:///C:/Documents%20and%20Settings/bozocv/Desktop/uniform-develop/demo/demo.html

Dont let change from .html() to .text() confuse you it is not related to this bug. It is related to other bug wich is allready fixed in new version(I saw other closed issue).

@fidian
Copy link
Collaborator

fidian commented Jan 15, 2013

You will need to call $.uniform.update() after the form gets reset. Normally, this is super trivial for other types of updates, but the values on the form are not changed until after the "reset" event is fired. Still, one can update the form with a little code like this:

$('form').on('reset', function () {
    setTimeout($.uniform.update, 1);
});

You can see a working example at this gist: https://gist.github.com/4539674

Adding this to the readme. Issue seems solved so I am closing it. Reopen it if the latest code on the development branch doesn't work for you.

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

No branches or pull requests

1 participant