Jquery sorted with regex

I am trying to figure out the correct regular expression for matching list item id.

For instance:

<ul id="MyList" class="connectedSortable">
    <li id="id=1-32">Item 1</li>
    <li id="id=2_23">Item 2</li>
    <li id="id=3">Item 3</li>
    <li id="id=4">Item 4</li>
    <li id="id=5">Item 5</li>
    <li id="id=6">Item 6</li>
</ul>

In the serialization method, I want it to pull everything after the equal sign (=). For example, for the first element I need the identifier 1-32, for the second I need it to be 2_23.

    $(function () {
        $("#MyList, #OtherList").sortable({
            connectWith: '.connectedSortable',
            update: function () {
                $("#MyListOrder").val($("#MyList").sortable('serialize', { regexp: '/(.+)[=](.+)/)' }));
            }
        }).disableSelection();
    });

I tried the above, but it didn’t quite work. My regex expression is incorrect, and I don't know what it should be. Ideas?

UDPATE: Instead of using the serialization method, I decided to use toArray. This way I get the whole ID and can rip out the part on which I don't want the server.

+3
source share
1 answer

"", /.../ , . :

.sortable('serialize', { expression: '(.+)=(.+)' })

.sortable('serialize', { expression: /(.+)=(.+)/ })

: http://jsbin.com/oqejo3/2

+4

Source: https://habr.com/ru/post/1747597/


All Articles