Closed mathiasselleslach closed 6 years ago
Hi @mathiasselleslach!
Internally, the plugin uses the "keyup" event to fire off a "keyboardChange" event... maybe binding to this event will work for you?
You can also rename the event (I wouldn't use "keyup" LOL) as follows:
$.keyboard.events.kbChange = "myRenamedKeyUpEvent";
Oh, or are you saying you must bind to a "keyup" event? Hmmm....
@Mottie ,
I figured it out. First of all I hooked in to the on click of a button (single letter on the keyboard) to manually fire the keyup.
At that point Drupal did fire the AJAX call for the autocomplete correctly. When I selected a value from the dropdown however, the value was not populated into the input field.
After some digging, this appeared to be because I was lacking the autoaccept. This is the JS I have in place now. Not sure if this is the cleanest solution, but it does work at this point.
$('input').on('click', function() {
$(this).keyboard({
usePreview: false,
autoAccept: true,
alwaysOpen: true,
});
$('.ui-keyboard-button').on('click', function() {
$('.ui-keyboard-input-current').trigger('keyup');
});
});
All suggestions for improvement are welcome of course.
Ps: You can consider this issue closed.
Many thanks
Mathias
Dear @Mottie ,
I am currently working on a Drupal implementation of the keyboard on a custom form. My custom form contains a Drupal form api ajax callback with autocomplete functionality.
The problem is that the ajax callback is only fired on keyup event in JS. The keyboard however does not seem to fire that event when a "key" is pressed on the on-screen keyboard?
I tried to implement the "change" method to trigger the keyup manually, but that results in a loop that re-triggers the change method again.
I was wondering if you would have any additional suggestion on how to go about this?
Drupal does not seem to provide an easy way of triggering just the AJAX callback individually.
The only solution i can see so far is to implement a custom ajax callback in JS myself;
Many thanks
best regards,
Mathias