jQuery Mobile Form - Reset button not clearing all fields

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

19-Feb-12 17:07
I've created a simple form for a jQuery Mobile website and it's working well. I've just added a "reset" button to the form so the user can reset the form if they wish, however I've noticed it only appears to clear out the text input fields and doesn't reset any radio buttons, select menus etc.

I've put an example of this at:

http://jsfiddle.net/vXzvZ/1/

Is this the case normally or am I missing something? If this is standard behaviour anyone have any ideas as to how to get all the form elements to reset regardless of their type?

Thanks
20-Feb-12 03:43
@databuzz: I don't think jQM automatically refreshes its widgets on form reset. You have to manually refresh them by calling the 'refresh' method.

Try Pablo's solution here:

http://stackoverflow.com/questions/8973703/jquery-mobile-reset-form-html-5

You could also attach the function as a 'reset' handler on the form, rather than as a 'click' handler on the button, which might be a more elegant approach.

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/

 
New posts
Old posts

Follow Elated