0

I made a keyboard plugin. When I click on values of the keyboard it succesfully fills the input box, but it doesn't trigger my event.

In a nutshell:

<form>
    <input id='testinput' type='text' name='test' value='' />
</form>

jQuery:

$('input').focus(function(){
    $('input').keyboard().show();
});

$('#test-input').on('input', function() {
   alert('change'); 
});

The code for the keyboard is a bit too big to show it here. It is attached in the fiddle. When I manually write something in the input it is triggered, but not via the keyboard.

Can someone point me in the right direction?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Matheno
  • 4,112
  • 6
  • 36
  • 53

1 Answers1

1

You are programatically inserting the characters when a user clicks so you will need to manually trigger the "input" event handler also in your plugin

click: function(e) {
  e.stopPropagation()
  e.preventDefault()
  this.select()
  this.$element.trigger('input')
}

FIDDLE

wirey00
  • 33,517
  • 7
  • 54
  • 65
  • Thanks! I had it almost right myself, but instead of input I had the ID of the input. Many thanks my hero! – Matheno Oct 06 '14 at 14:19
  • 1
    Its Failing Buddy,Try the combination some i/p from keybord some from input ,it fails – Shekhar Pankaj Oct 06 '14 at 14:24
  • @ShekharPankaj what's failing? I couldn't get it to fail - Are you sure the input has the focus when you are using the keyboard? – wirey00 Oct 06 '14 at 14:31