Modalview + Textarea + Keyboard open/close (bug?)

2 posts, 0 answers
  1. myTeamWorks
    myTeamWorks avatar
    15 posts
    Member since:
    Jan 2013

    Posted 23 Jan 2013 Link to this post


    I've a very strange behavior trying to close the keyboard when closing a modalview.

    My modalview is like this:
    <div id="modalview-create-post" data-role="modalview" style="width:100%;height:100%;" data-open="showCreateNewPost" data-init="initCreateNewPost">
                    <div id="modalview-post-content">
                            <a id="new-post-cancel" data-click="closeCreateNewPost" data-role="button">Cancel</a>
                            <a id="new-post" data-click="createPost" data-role="button">Post</a>
                            <span id="new-post-count"></span>
                        <textarea id="new-post-txt" class="watermark" counterSelector="#new-post-count" ></textarea>
    function closeCreateNewPost() {
    function forceBlurTextarea(textarea) {
        var cssClass = $(textarea).attr('class');
        $(textarea).attr('class', cssClass.replace("unwatermark", "watermark"));

    As you can see, my modalview contains a textarea and a cancel button to close the modalview. The cancel button is not at the same HTML-DOM level as the textarea.

    The first time I open the modalview, click inside the textarea (to make the keyboard appear) and then click on cancel to close the modalview, all is going well => modalview closes, keyboard automatically disappear

    The 2nd time I do this, the modalview also closes BUT the keyboard stays visible!

    Now if I put the 'cancel' button JUST AFTER the textarea (at the same HTML-DOM level as the textarea), it's working every time.

    Do you have an explanation on why this is happening?

    By the way, does it give a function to programmatically open/close the keyboard?

    Thanks for your support.
  2. Petyo
    Petyo avatar
    2436 posts

    Posted 25 Jan 2013 Link to this post


    From our experience so far, the correct way to close the soft keyboard would be to blur the input element. Please give that approach a try. 

    Kind regards,
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top