javascript - jQuery validation plugin not working after JQM page change -


I am currently working on a mobile html5 project. I am using jQuery validation plugin to validate the login screen with a form. I'm also using jQuery mobile with a single page template (I have different HTML files, but when the pages change, the JQ file reads and injects the contents of the new page in the DOM). App Junk to reload the page in every page:

  $ Mobile.changePage ("pageurl", {reloadPage: true});   


The first page is the login screen with a simple form for username and password. Everything goes well in the first shot: Verification plugin complains that the submit button is pressed and some fields are empty. If all the fields are ok and the submissions are pressed, then I call some AJAX call for the WS, I save the data in DB and the next page is displayed.

This is the code for the login screen:

  $ (document) .on ("pageinit", "#login_screen", function () {// this event every Once we show this JQM "Page", a fire occurs. Validate $ ("# Id_index_form") ({SubmitHandler: function (form) {user = form.user.value; password = form.psw.value; Login ();}}};}); Function Login () {// Log in WS (Omitted) // If the login is correct, then go to the next page using AOxX $ .mobile.changePage ("nextpage.html", {reloadPage: true}) Inject the next page; }   

One important thing is that I can not use the form created in the system, so a custom login function is called instead.

In the next screen, when the user returns to login, I change the page again:

  $ Mobile.changePage ("login.html", {reloadPage: true});   

And now the verification plugin does not work just for any long time. This is not valid, and when the submit is pressed, the form is cleared and nothing happens. The mobileinit incident was removed again as expected, there is no error in the console.

Am I missing something? How can I "restart" the plugin? Maybe it still thinks that the last call did not end?

Thanks in advance.


Update:
I am debugging a non-minimide plugin js file, and the problem is that it starts in a valid call In the first call, which is successfully completed, the plugin creates an identifier which binds the form, and it caches the verifier. In the second call, I will need to tie a new verification in the new form, and instead it is returning me to the old validator (linked to the old form).

Resolved:

What was happening: I have no idea. I know that this plugin binds on any form when valid is called and it binds it until the form is in the DOM. Along with this, it caches the validator, so after calling valid on the same form, the call returns the very validator.

What did I do: Before switching to the next page, I am from Form Dome.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -