Uncaught TypeError: $inp.rating is not a function | Symfony | Bootstrap | Twig

I have this error, but I don’t know why, the code seems correct…

enter image description here

templatesbase.html.twig

<head>
    <meta charset="UTF-8">
    <title>
        {% block title %}Welcome!
        {% endblock %}
    </title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <link href="{{ asset('css/star-rating.css') }}" media="all" rel="stylesheet" type="text/css"/> {% block stylesheets %}{% endblock %}
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="{{ asset('js/star-rating.js') }}" type="text/javascript"></script>
</head>

templatesproductindex.html.twig

<script>
    jQuery(document).ready(function () {
        var $inp = $('#rating-input');

        $inp.rating({
            min: 0,
            max: 5,
            step: 1,
            size: 'lg',
            showClear: false
        });

        $('#btn-rating-input').on('click', function () {
            $inp.rating('refresh', {
                showClear: true,
                disabled: ! $inp.attr('disabled')
            });
        });
        $inp.on('rating.change', function () {
            alert($('#rating-input').val());
        });
    });
</script>

Do you have any idea ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *