Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in JS console when entering text #168

Closed
callumprentice opened this issue May 10, 2013 · 4 comments
Closed

Error in JS console when entering text #168

callumprentice opened this issue May 10, 2013 · 4 comments

Comments

@callumprentice
Copy link

Hi! Great work and thank you for an excellent product.

I see an error in the JS console on OS X & Chrome 26.0.1410.65 when I enter text and press the Enter key in my keyboard (which I have set up to accept):

Uncaught TypeError: Object function (e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)} has no method 'replace' jquery.keyboard.js:698

I'm using this version of jQuery:

<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.10.2.min.js"></script>

and version Version 1.17.5 of jquery.keyboard.js

This is my code to add a keyboard to my page:

    $('#keyboard').keyboard({
        accepted: keyboardSearch,
        visible: function (e, keyboard, el) {
            keyboard.$preview.val('');
            searchHasFocus = true;
        },
        hidden: function (e, keyboard, el) {
            searchHasFocus = false;
        },
        display: {
            'bksp': "\u2190",
            'accept': 'enter',
            'default': 'ABC'
        },
        layout: 'custom',
        customLayout: {
            'default': [
                '1 2 3 4 5 6 7 8 9 0',
                'q w e r t y u i o p',
                'a s d f g h j k l {bksp}',
                'z x c v b n m , . \'',
                '{cancel} {space} {enter}'
                ]
        }
    });
    $.keyboard.keyaction.enter = function (base) {
        base.accept();
        $('form').submit();
    };

I haven't made a fiddle for this yet - but I can do if the error isn't obvious.

I was able to remove the error for me as per the code by adding
useCombos: false in my initialization.

Cheers.

@Mottie
Copy link
Owner

Mottie commented May 10, 2013

Hi @callumprentice!

That error doesn't look like code contained within the keyboard nor caret plugin. It could be another script interfering. But, I can add a safety measure to prevent an error at that line of code.

Maybe a fiddle would help. You can modify this demo to give you a starting point.

@callumprentice
Copy link
Author

Thanks @Mottie - managed to get a fiddle that illustrates it -

http://jsfiddle.net/E3wmT/1/

seems to be tickled when i open keyboard, enter keys with mouse (not keyboard) and hit enter.

seems to be caused by the $.keyboard.keyaction.enter = function (base) { line

@Mottie
Copy link
Owner

Mottie commented May 10, 2013

Interesting... if you return false; at the end of the updated enter function, the error goes away (demo):

$.keyboard.keyaction.enter = function (base) {
    base.accept();
    $('form').submit();
    return false;
};

I'll still look into fixing this so no error occurs.

@callumprentice
Copy link
Author

Great - thanks @Mottie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants