2016-10-03 56 views
0

請幫助我,我有一個代碼添加產品,我有使用ckeditor但我想要添加新的textarea使用ckeditor,並解決問題。我有一個附加。當我點擊按鈕使用函數append然後它不加載jquery。我不知道如何再次回調jquery。請幫我如何回調jquery後加載完整的web使用追加

<div class="form-group"> 
<div class="col-md-12 col-xs-12" style="margin: 0 auto; text-align: center"> 
<a onclick="appendText()" class="offsite" >Add Project</a> //function append 
<div class="append"></div> // Load append 
</div> 
</div> 
<script src="{{asset('assets/global/plugins/ckeditor/ckeditor.js')}}" type="text/javascript"></script> 
<script src="{{asset('assets/pages/scripts/components-editors.min.js')}}" async type="text/javascript"></script> 
<script> 
    function appendText() { 
     var txt1 = '<textarea class="ckeditor form-control" name="content_vi[]" rows="6" required></textarea>'; 

     $(".append").append(txt1); // Append new elements 
    } 
</script> 

回答

0

你需要得到一個jQuery對象引用<textarea> DOM節點,並在其上運行CKEDITOR。

例如:

$('<div><textarea><\/textarea><\/div>').appendTo('#parentNode').find('textarea').ckeditor(); 
+0

謝謝你幫助我。 (''parentNode')。find('textarea')。ckeditor();在$(「。append」)之後。append(txt1); //追加新的元素,這是行不通的。 –

+0

您需要一個ID爲'parentNode'的現有元素,或更改爲您需要的名稱。因此,當使用jQuery添加新的DIV> TEXTAREA時,創建一個DIV或其他東西並引用它的ID。 – JamesH

+0

雅,我有添加ID #parentNode - > var txt1 ='';但它不起作用 –