This is a migrated thread and some comments may be shown as answers.

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

1 Answer 76 Views
ModalView
This is a migrated thread and some comments may be shown as answers.
myTeamWorks
Top achievements
Rank 1
myTeamWorks asked on 23 Jan 2013, 01:23 PM
Hi,

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">
                    <div>
                        <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>
                    </div>
 
                    <textarea id="new-post-txt" class="watermark" counterSelector="#new-post-count" ></textarea>
                </div>
            </div>
function closeCreateNewPost() {
    forceBlurTextarea($('#new-post-txt'));
    $('#modalview-create-post').data('kendoMobileModalView').close();
}
function forceBlurTextarea(textarea) {
    $(textarea).val($(textarea).text());
    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.
Bastien

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 25 Jan 2013, 07:56 AM
Hi,

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,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ModalView
Asked by
myTeamWorks
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or