Bonjour a tous, j'ai repris l'exemple de jquery photo manager, pour deplacer des images d'un endroit a un autres.
Mon souci c'est que quand je drag and drop un élément ou que je click sur ma balise a pour déplacer mon élément celui ci fais bien l'action voulu, mais il s'efface de son endroit d'origine, alors que j'aimerai que oui il soit déplacer mais qu'il ne s'efface pas.
http://jqueryui.com/demos/droppable/#photo-manager
Voici l'exemple sur leur site vous verrez que si vous déplacer l'image elle s'efface de l'endroit initiale.
Je ne trouve pas l'endroit a effacer pour que ceci ne s'effectue plus, malgré mes recherche sur la doc jquery....
Mon jquery:
Code : 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 $(function() { // there's the gallery and the check var $gallery = $( "#gallery" ), $check = $( "#contentRightMenuFormResult" ); // let the gallery items be draggable $( "li", $gallery ).draggable({ helper: "clone", }); // let the check be droppable, accepting the gallery items $check.droppable({ accept: "#gallery > li", activeClass: "ui-state-highlight", drop: function( event, ui ) { deleteImage( ui.draggable ); }); // resolve the icons behavior with event delegation $( "ul.gallery2 > li" ).click(function( event ) { var $item = $( this ), $target = $( event.target ); if ( $target.is( "a.ui-icon-check" ) ) { deleteImage( $item ); } else if ( $target.is( "a.ui-icon-zoomin" ) ) { viewLargerImage( $target ); } else if ( $target.is( "a.ui-icon-closethick" ) ) { recycleImage( $item ); } return false; }); } ); }); // image deletion function var recycle_icon = "<a href='link/to/recycle/script/when/we/have/js/off' title='Supprimer de l’album' class='ui-icon ui-icon-closethick'>Recycle image</a>"; function deleteImage( $item ) { $item.fadeOut(function() { var $list = $( "ul", $check ).length ? $( "ul", $check ) : $( "<ul class='gallery ui-helper-reset'/>" ).appendTo( $check ); $item.find( "a.ui-icon-check" ).remove(); $item.append( recycle_icon ).appendTo( $list ).fadeIn(function() { $item /*.animate({ width: "48px" })*/ .find( "img" ) .animate({ height: "72px" }); }); }); } // image recycle function var check_icon = "<a href='link/to/check/script/when/we/have/js/off' title='Ajouter a l'album' class='ui-icon ui-icon-check'>Delete image</a>"; function recycleImage( $item ) { $item.fadeOut(function() { $item .find( "a.ui-icon-closethick" ) .remove() .end() .css( "width", "96px") .append( check_icon ) /*.find( "img" ) .css( "height", "72px" )*/ .end() .appendTo( $gallery ) .fadeIn(); }); } // image preview function, demonstrating the ui.dialog used as a modal window function viewLargerImage( $link ) { var src = $link.attr( "href" ), title = $link.siblings( "img" ).attr( "alt" ), $modal = $( "img[src$='" + src + "']" ); if ( $modal.length ) { $modal.dialog( "open" ); } else { var img = $( "<img alt='" + title + "' width='384' height='288' style='display: none; padding: 8px;' />" ) .attr( "src", src ).appendTo( "body" ); setTimeout(function() { img.dialog({ title: title, width: 400, modal: true, resizable: false, }); }, 1 ); } } // resolve the icons behavior with event delegation $( "ul.gallery > li" ).click(function( event ) { var $item = $( this ), $target = $( event.target ); if ( $target.is( "a.ui-icon-check" ) ) { deleteImage( $item ); } else if ( $target.is( "a.ui-icon-zoomin" ) ) { viewLargerImage( $target ); } else if ( $target.is( "a.ui-icon-closethick" ) ) { recycleImage( $item ); } return false; }); // resolve the icons behavior with event delegation $( "ul.gallery2 > li" ).click(function( event ) { var $item = $( this ), $target = $( event.target ); if ( $target.is( "a.ui-icon-check" ) ) { deleteImage( $item ); } else if ( $target.is( "a.ui-icon-zoomin" ) ) { viewLargerImage( $target ); } else if ( $target.is( "a.ui-icon-closethick" ) ) { recycleImage( $item ); } return false; }); });
Mon HTML :
Code : 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 <div id="contentBlock"> <ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix"> {% for affiche in attribu_image %} <li class="ui-widget-content ui-corner-tr"> <h6 class="ui-widget-header">{{ affiche.name|slice:":16" }}</h6> <img src="{% ids_images_prefix %}{% for thumb in affiche.element_thumb %}{{thumb}}{% endfor %}" alt="{{ affiche.name }}" height="72" /> <a href="{% ids_images_prefix %}{% for low in affiche.element_low %}{{low}}{% endfor %}" title="{{ affiche.price }} {{ affiche.description }} {% for tags in affiche.tags %} {{ tags }}, {% endfor %}" class="ui-icon ui-icon-zoomin">View larger</a> <form class="item-forms" action="{% url libertyproject.imagin.ajax.add_image %}" method="get"> {% csrf_token %} <input type="hidden" name="item_id" value="{{affiche.id}}" /> {% if selected_album %} <input type="hidden" name="selected_album_id" value="{{selected_album.id}}" /> {% else %} <input type="hidden" name="selected_album_id" value="{{selected_album}}" /> {% endif %} <!--<input class="ui-icon ui-icon-check item-send" type="submit" value="send in album" />--> <a href="link/to/check/script/when/we/have/js/off" title="Ajouter a l'album" class="ui-icon ui-icon-check">Ajouter a l'album</a> </form> </li> {% endfor %} </ul> <br class="spacer" /> </div>
Code : 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 <div id="contentRightMenuFormResult"> <ul id="gallery2" class="gallery2 ui-helper-reset ui-helper-clearfix"> {% for affiche in album0_items %} <li class="ui-widget-content ui-corner-tr"> <h6 class="ui-widget-header">{{ affiche.name|slice:":16" }}</h6> <img src="{% ids_images_prefix %}{% for thumb in affiche.element_thumb %}{{thumb}}{% endfor %}" alt="{{ affiche.name }}" height="72" /> <a href="{% ids_images_prefix %}{% for low in affiche.element_low %}{{low}}{% endfor %}" title="{{ affiche.price }} {{ affiche.description }} {% for tags in affiche.tags %} {{ tags }}, {% endfor %}" class="ui-icon ui-icon-zoomin">View larger</a> <form class="item-forms-remove" action="{% url libertyproject.imagin.ajax.remove_image %}" method="get"> {% csrf_token %} <input type="hidden" name="item_id" value="{{affiche.id}}" /> {% if selected_album %} <input type="hidden" name="selected_album_id" value="{{selected_album.id}}" /> {% else %} <input type="hidden" name="selected_album_id" value="{{selected_album}}" /> {% endif %} <!--<input class="ui-icon ui-icon-check item-send" type="submit" value="send in album" />--> <a href='link/to/recycle/script/when/we/have/js/off' title='Supprimer de l’album' class='ui-icon ui-icon-closethick'>Recycle image</a> </form> </li> {% endfor %} </ul> </div>
Merci d'avance !!!![]()
Partager