File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
19
19
$ ( function ( ) {
20
+ // Append the draggable widget to all the img objects
20
21
$ ( "img" ) . draggable ( {
22
+ // Capture the "stop drag" event
21
23
stop : function ( event , ui ) {
22
24
25
+ // Generate the img object with the new coordinates.
23
26
var img = {
24
27
"id" : $ ( this ) . attr ( 'id' ) ,
25
28
"position_y" : $ ( this ) . position ( ) . top . toString ( ) ,
26
29
"position_x" : $ ( this ) . position ( ) . left . toString ( )
27
30
} ;
28
31
32
+ // Send the request to the server
29
33
$ . ajax ( {
30
34
type : "PUT" ,
31
35
url : "/images/" + $ ( this ) . attr ( 'id' ) + ".json" ,
32
36
data : JSON . stringify ( img ) ,
33
37
contentType : 'application/json' ,
34
38
dataType : 'json' ,
39
+
40
+ // In case that an error happens, capture it and show the details.
35
41
error : function ( xhr , msg , error ) {
36
42
alert ( msg + ": " + error ) ;
37
43
}
You can’t perform that action at this time.
0 commit comments