当前位置:网站首页>Learning to organize using kindeditor rich text editor in PHP
Learning to organize using kindeditor rich text editor in PHP
2022-06-24 10:18:00 【Wandering in memory of Yu Fei】
Learn to organize in php Use in KindEditor Rich text editor
1、 Download editor
Download link : download - KindEditor - On-line HTML Editor
2、 Deploy kindeditor Editor
Unzip the downloaded package and put it in the program directory of the website
3、 stay html The editor is introduced into the page
Create a text field textarea
<textarea name="content" id="Contents" style="width:600px;height:450px;"></textarea>
Introduce on the page js file
<script src="/static/kindeditor/kindeditor-all-min.js"></script>
<script src="/static/kindeditor/lang/zh-CN.js"></script>
Initialize editor
<script>
// Editor
var KE;
KindEditor.ready(function (K) {
KE = K.create('#Contents', {
allowFileManager: true, // Browse the picture space
filterMode: false, //HTML Special code filtering
afterBlur: function () {
this.sync(); }, // Editor lost focus (blur) The callback function to execute when ( The editor's HTML Data synchronization to textarea)
afterUpload: function (url, data, name) {
// The callback function executed after uploading the file , It has to be for 3 Parameters
if (name == "image" || name == "multiimage") {
// When uploading pictures individually or in batches
var img = new Image(); img.src = url;
img.onload = function () {
// The image must be loaded to get the size
if (img.width > 100) {
KE.html(KE.html().replace('<img src="' + url + '" width="100" height="100"/>', '<img src="' + url + '" width="100" height="100px"/>'))
//KE.html(KE.html().replace('<img src="' + url + '" width="300"/>', '<img src="' + url + '" width="300"/>'))
}
}
}
}
});
KindEditor.create('#Contents', {
allowImageUpload: false, resizeType: 1, width: "600px", height: "300px" });
});
</script>
4、Ajax Cannot get... When submitting the form KindEditor Content
1、 problem : When used Ajax When you submit the form ,KindEditor Can't get the content of ,HTML Data is not available .
2、 reason :jax When submitting ,KindEdito Of HTML The data hasn't been synchronized to the form yet .
3、 solve : Use http://kindeditor.net/doc3.php?cmd=config Of afterBlur attribute .
KindEditor.ready(function (K) {
window.editor = K.create('#AContent', {
// key , Execute when you lose focus this.sync(), Synchronize the entered value to textarea in ;
afterBlur: function () {
this.sync();
}
});
});
Used on it afterBlur Method does a process , This method is triggered when the edit box is out of focus , Then do data synchronization
边栏推荐
- Detailed explanation of PHP singleton mode
- Desktop software development framework reward
- What are the characteristics of EDI local deployment and cloud hosting solutions?
- 正规方程、、、
- leetCode-223: 矩形面积
- 整理接口性能优化技巧,干掉慢代码
- SQL sever基本数据类型详解
- Yolov6: the fast and accurate target detection framework is open source
- Programming questions (continuously updated)
- Is there a reliable and low commission futures account opening channel in China? Is it safe to open an account online?
猜你喜欢

Wechat applet learning to achieve list rendering and conditional rendering

415-二叉树(144. 二叉树的前序遍历、145. 二叉树的后序遍历、94. 二叉树的中序遍历)

canvas无限扫描js特效代码

leetCode-223: 矩形面积

Mise en œuvre du rendu de liste et du rendu conditionnel pour l'apprentissage des applets Wechat.

numpy.linspace()

CVPR 2022 Oral | 英伟达提出自适应token的高效视觉Transformer网络A-ViT,不重要的token可以提前停止计算

How does home office manage the data center network infrastructure?

Producer / consumer model

4.分类管理业务开发
随机推荐
416-二叉树(前中后序遍历—迭代法)
学习整理在php中使用KindEditor富文本编辑器
Wechat applet learning to achieve list rendering and conditional rendering
Is there a reliable and low commission futures account opening channel in China? Is it safe to open an account online?
Desktop software development framework reward
PHP encapsulates a file upload class (supports single file and multiple file uploads)
静态链接库和动态链接库的区别
Phpstrom code formatting settings
leetCode-223: 矩形面积
416 binary tree (first, middle and last order traversal iteration method)
微信小程序rich-text图片宽高自适应的方法介绍(rich-text富文本)
Development of anti fleeing marketing software for health products
记录一下MySql update会锁定哪些范围的数据
Leetcode-1089: replication zero
Tutorial (5.0) 08 Fortinet security architecture integration and fortixdr * fortiedr * Fortinet network security expert NSE 5
SQL Sever关于like操作符(包括字段数据自动填充空格问题)
Using pandas to read SQL server data table
Regular matching mailbox
leetCode-929: 独特的电子邮件地址
23. Opencv——图像拼接项目