Uncaught Error: Syntax error, unrecognized expression:

Posted 3 months ago by behnampmdg3

Hi;

First consloe.log prints the number correctly however #module_counter_' + module_id produces the error. What am I missing?

Uncaught Error: Syntax error, unrecognized expression: #module_counter_[object HTMLCollection]
$( ".sortable_lessons" ).sortable({
        update: function( ) {
            var idsInOrder = $(this).sortable('serialize');
            var module_id= idsInOrder.substr(0, idsInOrder.indexOf('_')); 
            console.log(module_id);  //  First consloe.log
            $.ajaxSetup({
            headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
            });
            $.ajax({
                type:'post',
                url: '/lessons/sort',
                data: idsInOrder
            });
        },
        stop: function () 
            {
              $('.sortable_lessons > li').each(function (i) {
                $(this).find('#module_counter_' + module_id).html(i + 1);
              });
            }
    });

Please sign in or create an account to participate in this conversation.