我在控制台中遇到这个错误,它与我正在使用的js脚本有关(Trumbowyg-WYSIWYG:http://alex-d.github.io/Trumbowyg/)
以下是带有错误的浏览器控制台的图片:
当我单击(index):166
时,它会在源代码中显示:
id_content
是WSYIWYG编辑器的id
,这是我的js
文件中使其工作所需的函数:
$('#id_content').trumbowyg({
});
我看过其他的解决方案,他们说要在其他js脚本之前加载jquery脚本,但我已经在做了,它没有解决任何问题。有人知道问题出在哪里吗?顺便说一句,我使用这个包将它与django集成:https://github.com/sandino/django-trumbowyg,不确定这是否会改变什么。我只需在表单中加载小部件,如下所示:
^{pr2}$完整html部分:
< div >
< textarea
cols = "40"
id = "id_content"
name = "content"
rows = "10" >
< / textarea >
< script >
$("#id_content").trumbowyg({
lang: "en",
semantic: true,
resetCss: true,
autogrow: true,
removeformatPasted: true,
btnsDef: {
image: {
dropdown: ['upload', 'insertImage', 'base64', 'noembed'],
ico: 'insertImage'
}
},
btns: [
['formatting'],
'btnGrp-semantic',
['link'],
['image'],
'btnGrp-justify',
'btnGrp-lists',
'video',
['horizontalRule'],
['removeformat'],
['fullscreen'],
['viewHTML']
],
plugins: {
upload: {
serverPath: '/trumbowyg/upload_image/',
fileFieldName: 'image',
statusPropertyName: 'message',
urlPropertyName: 'file'
}
}
});
< / script >
< / div >
编辑:请记住,一切都很好,但我仍然遇到这个错误。这不是一个重复的问题,我尝试过这些解决方案,但没有一个有效。在
html文件结束,脚本加载良好:
...
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.1.1.min.js"><\/script>')</script>
<script src="/static/js/jquery-jvectormap-2.0.3.min.js"></script>
<script src="http://jvectormap.com/js/jquery-jvectormap-world-mill.js"></script>
<script type="text/javascript" src="/static/js/base.js"></script>
<!--<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>-->
<script src="/static/js/Trumbowyg-master/dist/trumbowyg.js"></script>
</body>
这意味着您的页面没有加载jQuery。在
检查network选项卡,看看jQuery在加载时是否有问题。在
或者
确保您的代码是在jQuery之后执行的。在
相关问题 更多 >
编程相关推荐