KnockoutJs cannot update the control value on mobile devices.

Source: Internet
Author: User

KnockoutJs cannot update the control value on mobile devices.

Recently, I used cordova (phonegap) to write a mobile app. The form is complicated and knockoutJs is used as the front-end MVVM framework for data binding.

However, sometimes (in fact, every time) if you finally edit a value in the input, and then click the Save button directly (using the JQM tap event, the same is true for touchend ), the value of the control with the last focus is not updated.

It is estimated that KO's value binding is by default to update the value in view model when the control triggers the change event, but it does not know why clicking the Save button does not trigger the last change event in the input.

The solution is also very simple. in the response event of the Save button, manually trigger the change of the current control:

1: if (document. activeElement ){
2: $ (document. activeElement). trigger ("change ");
3 :}


This problem does not exist in PC browsers, so it was not found when using the Ripple simulator, but this problem exists on iOS and android. I don't know why ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.