Skip to content

Re-creating keyboard with mobile extension fails #366

Description

@mpf82

I want to enable/disabe virtual keyboard for some input fields via code in a mobile environment.

I've stumbled upon this issue: #337 and tried to adapt my code according to the (no longer working) example found here: http://jsfiddle.net/Mottie/n2yh4ym9/2/

My code currently works 1 time (enable -> disable), but once I try to enable the keyboard for the second time and click into the input field, I get the following error:

_Uncaught TypeError: undefined is not a function_

in jquery.keyboard.extension-mobile.js:97

code:

base.$keyboard.css('visibility', 'hidden');

Everything works fine if I do not add the mobile extension (excep from the keyboard looking weird, which is not acceptable).

You can reproduce the error with the following lines of code:
(I'm not familiar with creating a jsfiddle example, sorry)

HTML:

        <input id="input_test7_cb" type="checkbox" class="ui-btn" />
        <input id="input_test7" value="my input 7 ..." data-clear-btn="true" />

Javascript:

jQuery( document ).on( "pagecreate", function( event ) {

    $("#input_test7_cb").on('change', function () {
        console.log("Checkbox changed");
        var kb;
        var $input = $("#input_test7");
        if (this.checked) {
            $input
                .keyboard({})
                .addMobile(); // this will break the code after the first destroy()
        } else {
            kb = $input.getkeyboard();
            if (kb) {
                kb.destroy();
            }
        }
    });
}); // DOM ready

Environment:

  • Virtual keyboard: 1.23.2
  • JQuery: 2.1.3
  • JQuery Mobile: 1.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions