Wednesday, June 27, 2012

Windows 8 Enter on textbox navigates back. WinJS app

Why would this happen? Here is the cause.
  1. The default page adds  “win-backbutton” button to the  header of each page.
  2. The HTML5 button tag by default set to Submit Button
  3. Since we are running in a browser, hitting the enter key “clicks” the first submit button
  4. The navigator class handles the click event of “win-backbutton” and calls nav.back()

How to resolve it? Here is the solution.

<button class="win-backbutton" type="button" disabled></button>

Change the type of the back button  In the header of the secondary page, set the button type to “button” . That's it problem solved

No comments:

Post a Comment