Bonjour,

J'ai un petit problème qui me fait tourner en bourrique ( certainement le syndrome du nez dans le guidon :-) ).

Alors voilà, j'utilise le widget jquery accordion sortable, jusque le pas de problème sauf que dans l'option sortable je souhaite spécifier des bloques non déplaçable et non triable.
Bon, la aussi pas de problème, la ou j'ai un souci c'est que je ne souhaite pas qu'un élément déplaçable puisse s'interposer entre deux non déplaçables est la ....
voici mon code, qui fonctionne avec l'option "handle: "h3:not(.not-sort)"", mais pas avec "items: ".group:not(.not-sort)",".
La checkbox dans chaque groupe sert justement à ajouter ou supprimer la liaison, j’espère être claire , c'est ici que le code ne fonctionne pas et finalement les groupes restent mobiles.

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<html>
    <head>
        <link rel="stylesheet" href="jquery-ui/themes/base/jquery-ui.min.css">
    </head>
    </body>
    <button type="button" class="btn  btn-warning btn-sm btnNewChar">New Level</button> <input type="checkbox" name="moveable" id="moveable" checked>  Moveable
 
        <div id="point-char" >
            <div class="group not-sort">
                <h3 data-href="#char-1" class="not-sort">
                Niveau <indice>1</indice> - <info></info>
                </h3>
                <div >
                    <p>
                        <input type="hidden" name="order_1" id="order_1" value="1">
                    </p>
                    <table width="80%">
                        <tbody>
                            <tr>
                                <td colspan="4" width="100%"><input class="control-control" type="checkbox" id="same" name="same" checked=""> Accroche</td>
                            </tr>   
                            <tr>
                                <td colspan="4" width="100%">Niveau 1</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="group not-sort">
                    <h3 data-href="#char-2" class="not-sort">
                        Niveau <indice>2</indice> - <info></info>
                    </h3>
                    <div>
                        <p>
                            <input type="hidden" name="order_2" id="order_2" value="2">
                        </p>
                        <table width="80%">
                            <tbody>
                                <tr>
                                    <td colspan="4" width="100%"><input class="control-control" type="checkbox" id="same" name="same" checked=""> Accroche</td>
                                </tr>   
                                <tr>
                                    <td colspan="4" width="100%">Niveau 2</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
            </div>
        </div>
    </body>
    <script src="jquery/dist/jquery-2.2.4-min.js"></script>
    <script src="jquery-ui/jquery-ui-1.11.4.min.js"></script>
 
    <script>
    $(function(){   
        temp();
    });
 
    
    function temp(param){
        var targetParent = $('body');  
        var targetChar = targetParent.find("#point-char");
 
        targetChar.accordion({
                header: "h3",
                active: 0,
                heightStyle: "content",
                create: function( event, ui ) {
                    $(this).accordion("refresh");
                },
            })
            .sortable({
                axis: "y",
                //handle: "h3:not(.not-sort)",
                items: ".group:not(.not-sort)",
                stop: function( event, ui ) {
                    var el = $(this).find('.group');
                    for(var i=0 , len=el.length; i<len; i++){
                        $(el[i]).find('indice').text((i+1));
                        $(el[i]).find('input[id^="order_"]').val((i+1));
                    }
 
                    ui.item.children("h3").triggerHandler("focusout");
                    $(this).accordion("refresh");
                }
            }); 
 
 
 
 
        targetParent.on("click", ".btnNewChar" ,function(){         
            {
            var order = (targetChar.find('.group').last().length > 0)? parseInt(targetChar.find('.group').last().find('input[id^="order_"]').val(),10) + 1 : 1;
            var indice = targetChar.find('.group').length + 1;
            var moveable = targetParent.find('#moveable').is(':checked') ;
            console.log(moveable);
 
            addLine(targetChar , '#char-' + order , indice, order, moveable);
            
            targetChar.find('.group h3').last().click();
            }
        }).on("click", "#same" ,function(){    
            {
            var cbx = $(this);    
          
            var group = $(this).closest('.group');    
      
            var h3 = group.find('h3');
  
            var idCHar = h3.attr('data-href');
       
 
            if(cbx.is(':checked')){
                group.addClass('not-sort');
                h3.addClass('not-sort');
                group.prev('.group').addClass('not-sort');
                group.prev('.group').find('h3').addClass('not-sort');
            }else{
                group.removeClass('not-sort');
                h3.removeClass('not-sort');
                group.prev('.group').removeClass('not-sort');
                group.prev('.group').find('h3').removeClass('not-sort');
            }
            
            targetChar.accordion("refresh").sortable("refresh");
            console.log(targetChar);
            
            }
        });
 
        function addLine(target, nameTarget, indice, order, sortable){
            sortable = (sortable == undefined)? true : sortable;
            
            var etape = '';
            var sort = ((!sortable)? 'not-sort' : '');
            var etapeNoSame = '<input class="control-control" type="checkbox" id="same" name="same" '+  ((sortable)? '' : 'checked')  +' > Accroche';
            
            var str = ` <div class="group ${sort}" >
                            <h3 data-href="${nameTarget}" class="${sort}">Niveau <indice>${order}</indice> - <info></info></h3>
                            <div>
                                <p>
                                    <input type="hidden" name="order_${indice}" id="order_${indice}" value="${order}" >
                                </p>
                                <table width="80%">
                                    <tr>
                                        <td colspan="4" width="100%">${etapeNoSame}</td>
                                    </tr>   
                                    <tr>
                                        <td colspan="4" width="100%">Niveau ${indice}</td>
                                    </tr>
                                </table>
                            </div>
                        </div>`;
                        
            //target.append(str).accordion("refresh").sortable("refresh");
            target.append(str).accordion("refresh");
        }
        
    }
 
 
    </script>
</html>

Merci par avance