2016-11-21 27 views
0

我有兩個彈出窗口。如果我點擊創建按鈕,一個彈出窗口將打開。假設彈出窗口中有3個rowse。 a)第1行 - >名字; Row2->姓氏; Row3-> Email按鈕 b)如果我點擊電子郵件按鈕,它會打開一個彈出窗口。在這個彈出我有CkEDITOR。所以,無論在這個ckediotr中輸入即時消息,我將這些值存儲在隱藏在第一個彈出窗口中的輸入中。 c)然後點擊第一個彈出框中的提交按鈕,彈出關閉並重定向到索引頁。值也在數據庫中正確存儲。 問題: 一旦價值再次存儲在數據庫中,即時計劃創建一個新的表單,即時點擊郵件按鈕和ckediotr將打開。但之前的數值仍然存在於CKediotr中。如何從ckeditor中刪除現有的值?值不是從ckeditor清除

 <form method="post" id='form'> 
     <textarea id="editor1" name="editor1"></textarea> 
     <input type="submit" value="Save"/> 
     <script> $(document).ready(function(){ var test = localStorage.setValueInCkeditor_create; if(test!='' || test!='undefined') { CKEDITOR.instances.editor1.setData(test); } $('#form').submit(function(){ window.parent.$("#create_ck_e‌​ditor").val(CKEDITOR‌​.instances.editor1.g‌​etData()); localStorage.setItem("setValueInCkeditor_create", CKEDITOR.instances.editor1.getData()); 
parent.$.colorbox.close(); return false; }); }); 
     </script> 
+0

<形式方法= 「POST」 ID = '形式'> karthik

回答

0

setData()功能將清除CKEditor的

for (instance in CKEDITOR.instances){ 
    CKEDITOR.instances[instance].updateElement(); 
    CKEDITOR.instances[instance].setData(''); 
} 

您可以創建常見功能,並調用它的提交事件

function clearCke(){ 
    for (instance in CKEDITOR.instances){ 
     CKEDITOR.instances[instance].updateElement(); 
     CKEDITOR.instances[instance].setData(''); 
    } 
} 
$(document).ready(function(){ 
    $('#from').submit(function() { 
     clearCke(); 
    }); 
}); 
0

在阿賈克斯做過了下面的命令後部分,問題已解決

localStorage.removeItem("setValueInCkeditor_create");