T
T
Tema2015-10-08 14:27:26
Drupal
Tema, 2015-10-08 14:27:26

Drupal 7, ajax on form, how to implement keyup event?

Good day!
In Drupal, by default, if you add #ajax to the form element without the event property, ajax fires after the element is unfocused (change). If I put:

'#type' => 'textfield',
'#ajax' => array(
    ...,
    'event' => 'keyup' // | keypress и тд
)

works, but after each entered character, the focus is reset from the field and therefore the input cannot be continued, you have to return the cursor back. Why is this happening? How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serverkon, 2015-10-17
@servekon

Try like this:

'#type' => 'textfield',
'#ajax' => array(
    ...,
    'event' => 'keyup' // | keypress и тд
   'keypress' => TRUE,
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question