Binding Behavior—blur vs. keydown question

7 posts, 0 answers
  1. TJ
    TJ avatar
    58 posts
    Member since:
    Aug 2013

    Posted 05 Jan 2015 Link to this post

    Hey all,

    I noticed a bit of confusing behavior. I was implementing data binding for the first time and it seemed to only be working one way—that is, JS changes were appearing in the UI, but not vice versa.

    After some further digging I found that UI changes were occurring in JS, but not until my TextFields were blurred. This caused an issue in my login form, because after typing a username I was immediately clicking a button (that performed the actual login in a click handler). In that click handler the observable object's property bound to the TextField had not reflected what I had just typed. If I click elsewhere on the screen before clicking the button my changes are reflected as expected.

    In my web developer state of mind this tells me that the data is probably being synced on blur rather than on keydown (or whatever iOS and Android call it). Is that correct? If so I could see that creating problems.

    If my descriptions of what I'm doing were confusing let me know and I can clarify.

    Thanks,
    TJ
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 06 Jan 2015 Link to this post

    Hi,

    Do you observe this behavior in Android or in iOS or in both platforms?

    I am asking this, because I have recently changed this behavior in Android, i.e. the text property is updated only after the EditText (this is what represents our TextField in Android) widget loses focus. Which turned out to be a bad idea, since the widget you tap on might not be focusable in touch mode, which may cause the EditText widget to never lose focus. This seems like your case.

    Anyway, I am currently developing a new property which will let the user specify the behavior he wants. It will be called updateTextTrigger and will be an enum with two possible values -- FocusLost and TextChanged. The default value will be TextChanged which will be update the TextField.text property on every single character that the end user types.

    This change will come with the next version we release. Please, let me know if the problem persists.

    Regards,
    Rossen Hristov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. TJ
    TJ avatar
    58 posts
    Member since:
    Aug 2013

    Posted 06 Jan 2015 in reply to Rossen Hristov Link to this post

    Hi Rossen,

    I actually only see this problem on iOS. On Android my data syncs as I would expect.

    TJ
  4. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 07 Jan 2015 Link to this post

    Hi,

    Yesterday, I have implemented the new feature. If you set your TextField.updateTextTrigger to textChanged, the binding will be updated on every single character typed by the user. On the other hand, if you set it to focusLost the binding will be updated only after the user is done editing. This happens when he closes the soft keyboard.

    Do you think that the textChanged option will solve your problem?

    Regards,
    Rossen Hristov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Marko
    Marko avatar
    5 posts
    Member since:
    May 2014

    Posted 07 Jan 2015 Link to this post

    textChanged should be default in all cases since that's what users expect.
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 07 Jan 2015 Link to this post

    Hi,

    textChanged will be the default value.

    Regards,
    Rossen Hristov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. TJ
    TJ avatar
    58 posts
    Member since:
    Aug 2013

    Posted 07 Jan 2015 Link to this post

    Hey Rossen,

    The ability to choose between textChanged and focusLost (with textChanged being the default) is what I would expect and want.

    Thanks!
    TJ
Back to Top