diff --git a/app/assets/javascripts/habits.js.coffee b/app/assets/javascripts/habits.js.coffee index 3c0c938f74..3a2781392d 100644 --- a/app/assets/javascripts/habits.js.coffee +++ b/app/assets/javascripts/habits.js.coffee @@ -3,40 +3,22 @@ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ $(document).ready -> - $("#habits").sortable - axis: "y" - dropOnEmpty: false - cursor: "move" - items: "li" - opacity: 0.4 - scroll: true - update: -> - $.ajax - type: "post" - data: $("#habits").sortable("serialize") - dataType: "script" - complete: (request) -> - $("#habits").effect "highlight" - - url: "/habits/sort" - -$(document).ready -> - $("#daily").sortable - axis: "y" - dropOnEmpty: false - cursor: "move" - items: "li" - opacity: 0.4 - scroll: true - update: -> - $.ajax - type: "post" - data: $("#daily").sortable("serialize") - dataType: "script" - complete: (request) -> - $("#daily").effect "highlight" - - url: "/habits/sort" + $.each ['#habits', '#daily'], (index, list_id) -> + $(list_id).sortable + axis: "y" + dropOnEmpty: false + cursor: "move" + items: "li" + opacity: 0.4 + scroll: true + update: -> + $.ajax + type: "post" + url: "/habits/sort" + data: $(list_id).sortable("serialize") + dataType: "script" + complete: (request) -> + $(list_id).effect "highlight" (($) -> $.fn.highlight = -> @@ -45,4 +27,4 @@ $(document).ready -> background: "yellow" $(this).fadeIn() -) jQuery \ No newline at end of file +) jQuery