Open tised opened 2 years ago
Just pinging here, as it quite serious issue for us
Ping again :)
对源码做如下修改:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="normalize.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="checkbox_style.css">
</head>
<body>
<div id="editor" contenteditable="true"></div>
<script type="text/javascript" src="rich_editor.js"></script>
</body>
</html>
checkbox_style.css
input[type=checkbox] {
cursor: pointer;
position: relative;
}
input[type=checkbox]:not([class=checkbox-checked]):after {
position: absolute;
top: 0;
background-color: white;
width: 18px;
height: 18px;
display: inline-block;
visibility: visible;
padding-left: 0px;
text-align: center;
content: '';
border-radius: 2px;
box-sizing: border-box;
border: 1px solid #ddd;
}
.checkbox-checked::after {
position: absolute;
top: 0;
background-color: blue;
width: 18px;
height: 18px;
display: inline-block;
visibility: visible;
padding-left: 0px;
text-align: center;
content: '';
border-radius: 2px;
box-sizing: border-box;
border: 1px solid #ddd;
}
/**选中对号样式*/
.checkbox-checked::before {
content: '';
position: absolute;
top: 1px;
left: 6px;
width: 4px;
height: 10px;
border: solid white;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
z-index: 1;
}
rich_editor.js 最后面添加
// 复选框点击事件
RE.editor.addEventListener("click", function(ev){
var target = ev.target || ev.srcElement;
if(target.nodeName.toLowerCase() == 'input' && target.type == 'checkbox'){
if(target.className == 'checkbox-checked'){
target.removeAttribute("class");
}else {
target.className = 'checkbox-checked';
}
}
});
Hello, I found out that checkbox state after checking it not saved in HTML. so it appears always unchecked
Is there are way to fix that ?