This is a migrated thread and some comments may be shown as answers.

Binding Behavior—blur vs. keydown question

6 Answers 23 Views
NativeScript Insiders
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
TJ
Top achievements
Rank 1
TJ asked on 05 Jan 2015, 09:31 PM
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

6 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 06 Jan 2015, 08:26 AM
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.

 
0
TJ
Top achievements
Rank 1
answered on 06 Jan 2015, 03:43 PM
Hi Rossen,

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

TJ
0
Rossen Hristov
Telerik team
answered on 07 Jan 2015, 07:47 AM
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.

 
0
Marko
Top achievements
Rank 1
answered on 07 Jan 2015, 08:05 AM
textChanged should be default in all cases since that's what users expect.
0
Rossen Hristov
Telerik team
answered on 07 Jan 2015, 09:20 AM
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.

 
0
TJ
Top achievements
Rank 1
answered on 07 Jan 2015, 08:53 PM
Hey Rossen,

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

Thanks!
TJ
Tags
NativeScript Insiders
Asked by
TJ
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
TJ
Top achievements
Rank 1
Marko
Top achievements
Rank 1
Share this question
or