Mottie / Keyboard

Virtual Keyboard using jQuery ~
http://mottie.github.io/Keyboard/
Other
1.78k stars 723 forks source link

Can't open the keyboard progamatically #509

Closed willrbaar closed 7 years ago

willrbaar commented 7 years ago

I've been trying to use your keyboard. I have been able to set up the basic scenario where I have the element

*"<textarea type="hidden" id="keyboard" placeholder="Enter Text..."></textarea>"* `set up and I click on it and the keyboard appears.

I am having a hard time getting beyond this point. I have tried to use your example code under your usage section to open the keyboard programmatically. I have used your example and included <button class="open">Open Keyboard</button> in a division,

and the following code under script:

$('button.open').click(function(){
  $('#keyboard').getkeyboard().reveal();
});

I even did a:
" var keyboard = $('#keyboard').getkeyboard();
MottieKeyboardProblem.txt

to make sure I had an object to work with.

The problem I am having is that the DOM tells me that the: "Object doesn't support property or method 'getkeyboard'". I have tried a lot of stuff, but nothing works. I am new to working in javascript and I must be doing something wrong. I've attached a copy of my code.

Mottie commented 7 years ago

Hi @willrbaar!

It sounds like the keyboard hasn't been initialized yet... make sure to use this code before attempting to programmically open the keyboard:


$(function() {
  $('#keyboard').keyboard();

  // now this code should work
  $('button.open').click(function(){
    $('#keyboard').getkeyboard().reveal();
  });
});
willrbaar commented 7 years ago

Rob: Thanks for the quick response. I’m not very familiar with JavaScript and I appreciate your help. One of the things I was wondering is if I am getting an empty object back when we try to initialize? I used your code as is, and got the following response from the browser

.....”jQuery.Deferred exception: Object doesn't support property or method 'keyboard' TypeError: Object doesn't support property or method 'keyboard' at Anonymous function”.

I modified your code as follows to try to get away from an anonymous function, but it comes back with...”Unable to get property 'getkeyboard' of undefined or null reference”

Githubissues.
  • Githubissues is a development platform for aggregating issues.