nicEdit 面板不出现
nicEdit panel does not appear
我正在使用 nicEdit 作为本地站点的记事本编辑器。我使用复选框调用 nicEdit 函数(注释),但面板根本不显示。甚至警报也没有出现。
还有其他三个使用cookie保存笔记的功能:
//annotation
function annotation(player1) {
bkLib.onDomLoaded(function(){
new nicEditor({
fullPanel : true,
onSave : function(content, id, instance) {
var player_name = document.getElementById('player1').value;
alert(player_name);
checkCookie(player_name);
setCookie(content,player_name);
}
}).panelInstance('myArea');
});
}
function setCookie(content,player) {
var d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = player + "=" + content + "; " + expires;
}
//check if the coockie with current player name exists
function checkCookie(player_name) {
var pnote = getCookie( player_name );
//alert(pnote);
if ( pnote!="" ) {
$(".nicEdit-main").append(pnote);
} else {
if ( player_name != "" && player_name != null ) {
$(".nicEdit-main").append("");
alert("nothing");
}
}
}
//Gets the cookie content
function getCookie(player_name) {
var name = player_name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
<textarea style="height: 300px;" cols="52" id="myArea" name="myArea" style="width:450px; " ></textarea>
<input type="checkbox" onclick="annotation(player1)" id="player1" value="player1">player1 <br>
嗯,来电
bkLib.onDomLoaded(function(){}
你的注解功能是错误的。
下面是jquery处理点击事件的方法。
$('#player1').click(function () {
alert("player");
new nicEditor({
fullPanel : true,
onSave : function(content, id, instance) {
var player_name = document.getElementById('player1').value;
alert(player_name);
checkCookie(player_name);
setCookie(content,player_name);
}
}).panelInstance('myArea');
});
关于 jsfiddle 的完整示例 https://jsfiddle.net/cqcu0hbp/
我正在使用 nicEdit 作为本地站点的记事本编辑器。我使用复选框调用 nicEdit 函数(注释),但面板根本不显示。甚至警报也没有出现。
还有其他三个使用cookie保存笔记的功能:
//annotation
function annotation(player1) {
bkLib.onDomLoaded(function(){
new nicEditor({
fullPanel : true,
onSave : function(content, id, instance) {
var player_name = document.getElementById('player1').value;
alert(player_name);
checkCookie(player_name);
setCookie(content,player_name);
}
}).panelInstance('myArea');
});
}
function setCookie(content,player) {
var d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = player + "=" + content + "; " + expires;
}
//check if the coockie with current player name exists
function checkCookie(player_name) {
var pnote = getCookie( player_name );
//alert(pnote);
if ( pnote!="" ) {
$(".nicEdit-main").append(pnote);
} else {
if ( player_name != "" && player_name != null ) {
$(".nicEdit-main").append("");
alert("nothing");
}
}
}
//Gets the cookie content
function getCookie(player_name) {
var name = player_name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
<textarea style="height: 300px;" cols="52" id="myArea" name="myArea" style="width:450px; " ></textarea>
<input type="checkbox" onclick="annotation(player1)" id="player1" value="player1">player1 <br>
嗯,来电
bkLib.onDomLoaded(function(){}
你的注解功能是错误的。
下面是jquery处理点击事件的方法。
$('#player1').click(function () {
alert("player");
new nicEditor({
fullPanel : true,
onSave : function(content, id, instance) {
var player_name = document.getElementById('player1').value;
alert(player_name);
checkCookie(player_name);
setCookie(content,player_name);
}
}).panelInstance('myArea');
});
关于 jsfiddle 的完整示例 https://jsfiddle.net/cqcu0hbp/