我必须在wordpress网站中使用datepicker,其中插件使用相同的名称(数组)动态创建字段,相同的#id和相同的.class我尝试使用焦点使用它但我得到了错误
TypeError: inst is undefined
Run Code Online (Sandbox Code Playgroud)
请你好
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assests/jquery-ui.min.css" rel="stylesheet">
<script src="assests/jquery.js"></script>
<script src="assests/jquery-ui.js"></script>
</head>
<body>
<div class="mytemplate" style="display: none;">
<input id="datepicker" type="text" name="name[]">
</div>
<div class="dates">
<div>
<input id="datepicker" type="text" name="name[]">
</div>
</div>
<input type="button" value="Add more" onclick="myfunction()">
<script>
function myfunction() {
$(".mytemplate").clone().removeClass("mytemplate").show().appendTo(".dates");
}
</script>
<script>
$(document).on("focus", "#datepicker", function(){
$(this).datepicker();
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我得到了这个旧代码
// myenter.js, enter key is binded to insertParagraph command.
$.summernote.addPlugin({
name : 'myenter',
events : {
// redefine insertParagraph
'insertParagraph' : function(event, editor, layoutInfo) {
//you can use summernote enter
//layoutInfo.holder().summernote('insertParagraph');
// also you can use your enter key
layoutInfo.holder().summernote('insertNode', document.createTextNode("\r\n"));
// to stop enter key
//e.preventDefault();
}
}
});
Run Code Online (Sandbox Code Playgroud)
$('.summernote').summernote({height:300});
但现在添加插件的方法已经改变,我想通过此代码使用新版本的此功能
$.extend($.summernote.plugins, {
'myenter': function (context) {
console.log('myenter');
}
});
Run Code Online (Sandbox Code Playgroud)
但它根本没有被召唤
我试图通过
它获得相同的功能
summernote.onEnter
,
summernote.keyPress但它给出了错误..