Skip to content

Commit e34a979

Browse files
committed
Added comments to the code.
1 parent f046742 commit e34a979

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/assets/javascripts/application.js

+6
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@
1717

1818

1919
$(function() {
20+
// Append the draggable widget to all the img objects
2021
$("img").draggable({
22+
// Capture the "stop drag" event
2123
stop: function(event, ui) {
2224

25+
// Generate the img object with the new coordinates.
2326
var img = {
2427
"id": $(this).attr('id'),
2528
"position_y": $(this).position().top.toString(),
2629
"position_x": $(this).position().left.toString()
2730
};
2831

32+
// Send the request to the server
2933
$.ajax({
3034
type: "PUT",
3135
url: "/images/" + $(this).attr('id') + ".json",
3236
data: JSON.stringify( img ),
3337
contentType: 'application/json',
3438
dataType: 'json',
39+
40+
// In case that an error happens, capture it and show the details.
3541
error: function(xhr, msg, error) {
3642
alert(msg + ": " + error);
3743
}

0 commit comments

Comments
 (0)