Skip to content
New issue

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

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

Already on GitHub? # to your account

Keyboard doesn't show for widgets in Bootstrap modal dialogs #462

Closed
softelos opened this issue May 21, 2016 · 4 comments
Closed

Keyboard doesn't show for widgets in Bootstrap modal dialogs #462

softelos opened this issue May 21, 2016 · 4 comments

Comments

@softelos
Copy link

The dialog box is enabled from the same javascript that binds the keyboard to all inputs. The keyboard works perfectly for all inputs in the visible HTML but not for the invisible one that gets enabled when needed (pop up dialog box).

@softelos softelos changed the title Keyboard doesn't show for controls in Bootstrap pop up dialog boxes Keyboard doesn't show for widgets in Bootstrap pop up dialog boxes May 21, 2016
@softelos softelos changed the title Keyboard doesn't show for widgets in Bootstrap pop up dialog boxes Keyboard doesn't show for widgets in Bootstrap modal dialogs May 21, 2016
@Mottie
Copy link
Owner

Mottie commented May 21, 2016

Hi @softelos!

Please modify this demo to help me understand the problem.

@softelos
Copy link
Author

softelos commented May 21, 2016

Thanks for the response @Mottie !

I've updated the fiddle . As you can see when you press the button, the keyboard doesn't work for the input elements in the modal dialog.

@Mottie
Copy link
Owner

Mottie commented May 21, 2016

Because the dialog is being created using message: $('div#wrap').html(), you'll need to use a delegated bind on the document so the script knows when the modal is open and that the keyboard plugin needs to be initialized (demo):

$(document).on('shown.bs.modal', '.modal', function() {
  $('.modal input').keyboard({
      layout: 'qwerty',
      css: {
        // input & preview
        input: 'form-control input-sm',
        // keyboard container
        container: 'center-block dropdown-menu', // jumbotron
        // default state
        buttonDefault: 'btn btn-default',
        // hovered button
        buttonHover: 'btn-primary',
        // Action keys (e.g. Accept, Cancel, Tab, etc);
        // this replaces "actionClass" option
        buttonAction: 'active',
        // used when disabling the decimal button {dec}
        // when a decimal exists in the input area
        buttonDisabled: 'disabled'
      },
      usePreview: false
    })
    // activate the typing extension
    .addTyping({
      showTyping: true,
      delay: 50
    });
}).on('hide.bs.modal', '.modal', function() {
  // remove keyboards to free up memory
  $('.modal input').each(function() {
    $(this).data('keyboard').destroy();
  });
});

$('button#dialogButton').on('click', function() {
  bootbox.dialog({
    title: 'User Registration',
    message: $('div#wrap').html(),
    buttons: {
      save: {
        label: 'Save',
        class: 'btn-success'
      },
      cancel: {
        label: 'Cance',
        class: 'btn-default'
      }
    }
  });
});

And you'll need this css to override bootstrap's definition:

div.ui-keyboard {
  z-index: 2000;
}

@Mottie
Copy link
Owner

Mottie commented Jul 30, 2016

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.

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

No branches or pull requests

2 participants