Mottie / Keyboard

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

Change keyboard defaults #530

Closed afattahi54 closed 7 years ago

afattahi54 commented 7 years ago

I want to change some keyboard defaults css and position.

I test below but didn't work

$.extend($.keyboard.css,{
    input : ''
})
Mottie commented 7 years ago

Hi @afattahi54!

You should be modifying the defaultOptions:

$.extend($.keyboard.defaultOptions.css, {
  input: ''
});
afattahi54 commented 7 years ago

Thanks! I want to change the position and css so I used:

$.extend($.keyboard.defaultOptions.css, {
          input: ''
});

$.extend($.keyboard.defaultOptions.position, {
    of: null ,
    my: 'right center',
    at: 'left center',
    at2: 'left center',
    collision:'flipfit'

});

The above works

To reduce some line of codes, I try to merge two extend commands:

$.extend($.keyboard.defaultOptions, {
    css : {
        input: ''
    },
    position:{
        of: null ,
        my: 'right center',
        at: 'left center',
        at2: 'left center',
        collision:'flipfit'
    }
});

Which does not work ! It seems that the css property could not be set with this way.

Is it any way I can set defaults by using one $.extend

Mottie commented 7 years ago

With jQuery, you'll need to do add a true flag to perform a deep extend of the position object:

$.extend(true, $.keyboard.defaultOptions, {
    css : {
        input: ''
    },
    position:{
        of: null ,
        my: 'right center',
        at: 'left center',
        at2: 'left center',
        collision:'flipfit'
    }
});
Mottie commented 7 years ago

I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue the discussion in this thread.