2017-05-03 53 views
2

當輸入/文本字段變得聚焦(?)時,離子鍵盤打開。離子2 - 當點擊發送按鈕時保持鍵盤打開

但是當我點擊發送按鈕時,鍵盤消失。

即使我調用鍵盤插件的keyboard.show()方法,它會先消失,然後再次出現。

有沒有解決方案?

<textarea id="chat-text-area></textarea> 

sendMessage() { 
    if(window.cordova){ 
     this.keyboard.show() 
    } 
    if(this.form.valid){ 
     this.service.post(this.form.value).subscribe(res=>{ 
      document.getElementById('chat-text-area').focus() 
     }) 
    } 
} 

回答

0

你可以在隱藏事件中注入邏輯嗎?

window.addEventListener('native.keyboardhide', keyboardHideHandler); 

function keyboardHideHandler(e){ 
    if (something) // put your condition here 
     e.preventDefault(); 
} 
0

添加到您的發送按鈕:

(mousedown)="$event.preventDefault(); sendMessage($event)" 

我希望幫助:)

+0

大和簡單的解決方案,感謝,到目前爲止! – Unkn0wn0x

相關問題