0

我正在嘗試編寫Chrome擴展程序以填寫Google日曆中的事件描述 - 編輯事件窗口。但是當我使用Jquery添加文本時:$('textarea')。val('test');並保存該事件,說明不保存。有人知道如何解決這個問題嗎?Google日曆編輯事件 - 描述在由jQuery編輯時未保存

+0

你應該'觸發()''一個或change''爲textarea的input'事件。或切換到'$('textarea')。focus(); document.execCommand(「insertText」,虛假,「測試」)' – wOxxOm

+0

是幫助:)但是,當我把這個代碼在不同領域的onBlur事件,並按下保存,它就會excecuted但仍沒有保存:( – John

+0

通過每次onKeyUp事件調用此解決方案:)解決問題。謝謝! – John

回答

0

的解決方案是通過插入JS的文本,重點領域:

 $("#myfield").keyup(function(e){ 
      //text changed, update description field 
      text_tv = $(this).val(); 
      descr.val(''); 
      descr.focus(); 
      document.execCommand('insertText', false, convert_to_tv(text_tv)); 
      $(this).focus(); 
     });