【问题标题】:I got error related with jquery when installing summernote in codeigniter在codeigniter中安装summernote时出现与jquery相关的错误
【发布时间】:2019-11-24 18:50:43
【问题描述】:

jquery 有问题,不知道怎么办

我已按照https://summernote.org/getting-started/中的说明进行操作

我已在 head 标签中插入此代码

<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script> 
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.js"></script>

然后将textarea id设置为summernote

    <div class="form-group col-md-8">
      <label>Content</label>
        <textarea id="summernote" style="height: 200px;" name="isi_informasi"><?= $konten ?></textarea>
    </div>

并在body标签末尾插入此功能代码

<script type="text/javascript">
   $(document).ready(function() {
      $('#summernote').summernote();
   });
</script>

我在控制台中收到此错误消息

jQuery.Deferred exception: $(...).summernote is not a function TypeError: $(...).summernote is not a function
    at HTMLDocument.<anonymous> (http://localhost/okifftuh/admin/createInformation/2:533:30)
    at mightThrow (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js:3583:29)
    at process (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js:3651:12) undefined

jQuery.Deferred.exceptionHook @ jquery.js:3860
process @ jquery.js:3655
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
ready @ jquery.js:3920
completed @ jquery.js:3930

================================================ =========================

Uncaught TypeError: $(...).summernote is not a function
    at HTMLDocument.<anonymous> (2:533)
    at mightThrow (jquery.js:3583)
    at process (jquery.js:3651)

(anonymous) @ 2:533
mightThrow @ jquery.js:3583
process @ jquery.js:3651
setTimeout (async)
jQuery.readyException @ jquery.js:3868
(anonymous) @ jquery.js:3888
mightThrow @ jquery.js:3583
process @ jquery.js:3651
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
process @ jquery.js:3671
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
ready @ jquery.js:3920
completed @ jquery.js:3930

【问题讨论】:

  • 我在 Ques 中没有得到相同的代码......它工作正常......它可能与多个 JS 加载有关......你能提供你的页面 html代码...

标签: codeigniter codeigniter-3 summernote


【解决方案1】:

我认为这是与 jquery 的 Summernote 版本兼容性问题,请尝试分别使用 JQuery 3.2.0 和 Summernote 0.8.2 版本:

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.js"></script> 
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script> 
<link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.2/summernote.js" defer></script>

更详细的兼容性问题列表是here。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-06
    • 2018-08-11
    • 1970-01-01
    • 2017-11-15
    • 2020-07-12
    • 2014-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多