I"Ú(function() { window.dorsaleComments = { load: function() { return $("#dorsale-comments").map(function() { var container, url; container = $(this); url = this.dataset.url; return $.ajax({ url: url, success: function(data) { container.html(data); setupUploadInputs(container); dorsaleComments.setupCreateForm(); dorsaleComments.setupEditButtons(); return dorsaleComments.setupDeleteButtons(); } }); }); }, reload: function() { return dorsaleComments.load(); }, setupCreateForm: function() { return $("#new_comment").on("ajax:success", dorsaleComments.reload); }, setupEditForm: function() { return $("#edit_comment").on("ajax:success", dorsaleComments.reload); }, setupEditButtons: function() { return $("#dorsale-comment [href$=edit]").click(function() { var container, url; container = $(this).parents(".comment"); url = this.href; $.ajax({ url: url, success: function(data) { container.html(data); return dorsaleComments.setupEditForm(); } }); return false; }); }, setupDeleteButtons: function() { return $("#dorsale-comments [data-method=delete]").map(function() { return $(this).on("ajax:success", dorsaleComments.reload); }); } }; }).call(this); :ET