Home > Mobile >  TypeError: $(...).textcomplete is not a function inside Django
TypeError: $(...).textcomplete is not a function inside Django

Time:01-14

I'm trying to implement $('textarea-selector').textcomplete method from enter image description here

enter image description here

At the same time if I do the same in simple html file everything works well:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-1.10.2.js"></script>
    <script src="jquery.textcomplete.js"></script>

</head>
<body>

<textarea  id="textarea" rows="4" cols="50">...</textarea>

<script>

    $('.textarea').textcomplete([
        { // tech companies
            words: ['select', 'from', 'fct_table1', 'fct_table2', 'where', 'column1', 'column2'],
            match: /\b(\w{2,})$/,
            search: function (term, callback) {
                callback($.map(this.words, function (word) {
                    return word.indexOf(term) === 0 ? word : null;
                }));
            },
            index: 1,
            replace: function (word) {
                return word   ' ';
            }
        }
    ]);

</script>
</body>
</html>

How to make the script work inside Django?strong text

CodePudding user response:

<script src="{% static 'js/tasks/jquery-1.10.2.min.js' %} "></script>

Do this for all external scripts.

  •  Tags:  
  • Related