Это работает для меня. , Создать Div тег, внутри поместить ваш TextArea элемента
<div id="CommentTextArea">
<textarea name="comment_text" id="comment" rows="9" cols="50" ></textarea>
</div>
<button type="submit" id="send"> Send </button>
В вашем .js файл
$(function(){
// Initialize the Editor
$("#comment").wysihtml5({
toolbar: {
"size": "xs", //<buttonsize> // options are xs, sm, lg
"font-styles": false, // Font styling, e.g. h1, h2, etc.
"emphasis": true, // Italics, bold, etc.
"lists": false, // (Un)ordered lists, e.g. Bullets, Numbers.
"html": false, // Button which allows you to edit the generated HTML.
"link": true, // Button to insert a link.
"image": true, // Button to insert an image.
"color": false, // Button to change color of font
"blockquote": false, // Blockquote
}
});
// when the send button is clicked
$('#send').click(function(){
setTimeout(function(){
//remove wysihtml5Editor contents
$("#CommentTextArea").html('<textarea name="comment_text" id="comment" rows="9" cols="50" ></textarea>');
// and then Initialize the Editor again,
$("#comment").wysihtml5({
toolbar: {
"size": "xs", //<buttonsize> // options are xs, sm, lg
"font-styles": false, // Font styling, e.g. h1, h2, etc.
"emphasis": true, // Italics, bold, etc.
"lists": false, // (Un)ordered lists, e.g. Bullets, Numbers.
"html": false, // Button which allows you to edit the generated HTML.
"link": true, // Button to insert a link.
"image": true, // Button to insert an image.
"color": false, // Button to change color of font
"blockquote": false, // Blockquote
}});
}, 1000);
});
});
Какую версию jquery вы используете? 'live' устарел уже давно. вместо этого используйте 'on'. – karthikr
м не уверен, но последний из них ... – user1920656
нормально. то вы можете это сделать. '$ (document) .on ('click', '#cleartext', function() {$ ('# def_text'). data (" wysihtml5 "). editor.clear();});' чтобы узнать версия jquery: '$ .fn.jquery' – karthikr