cancel
Showing results for 
Search instead for 
Did you mean: 

Problem clearing a text input when implementing the onEnter event

Former Member
0 Kudos

Hello,

I have an input field which is bound to a text Context element called firstName.

I've created an event to clear the input field by writing at the onEnter event this action code:

wdContex.currentContexElement().setFirstName(null);

The problem is when the user enters the input field he still sees the "old" text. I beleive that the field needs to be "refreshed" with the new context it is bound to in some why but how?

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

This should work out of the box -- the only reason I guess is your error:

1. You are using wrong context element (or occasionally 2 different elements for InputField value binding and in onEnter action handler)

2. You have not assigned onEnter action handler to InputField

VS

Former Member
0 Kudos

Using a tooltip is the best solution, I guess

Former Member
0 Kudos

Hi,

1. You can use a label UIElement for the inputfield.

2. You can display the textmessage as a tooltip for the inputfield.

3. User should press ENTER to remove the text.

Regards, Anilkumar

Former Member
0 Kudos

IMHO, resetting the input field value to NULL if the user presses ENTER seems not to be a good idea.

To clear the input field, you can either set the value of the context attribute to NULL or "", both are ok.

Armin

Former Member
0 Kudos

All,

I think you all misunderstood me, let me clear my point:

The input fiels has a sefault value "Please enter your search here...". I would like that when the user enters the input filed in order to write his search criteria this default info messege will diappear instead of him need to delete it manually. I would like that to happen when the mouse focuses on the input field, before he pressed the Enter or hit the search key.

Former Member
0 Kudos

You can't do that because there is no onFocus event.

Give the input field a label, also for accessibility reasons.

Armin

Former Member
0 Kudos

Hi Roy,

I worked with ur code and it worked fine for me i.e., after the user enters a value and hits the ENTER key the value in the input field will be set to null.

onEnter event is triggered when we hit the enter key.

Hope this helps you.

Regards,

Vijith

Former Member
0 Kudos

try

wdContext.currentContexElement().setFirstName("");