Permalink
Browse files

Modify comment popup

  • Loading branch information...
1 parent 4a1b927 commit 1af0ae1f9d28198414eedb81c75b669aee17edb3 @amesel amesel committed Jul 19, 2012
@@ -6,3 +6,9 @@ $ ->
$('.add a').click ->
$('.add').toggleClass("close")
false
+
+ $(document).on 'click', 'span.comments', ->
+ $('div.comments').hide()
+ $("##{$(@).data("id")} div.comments").show()
+ $(document).on 'click', 'div.comments .close', ->
+ $('div.comments').hide()
@@ -161,7 +161,7 @@ body.parties_show
+blue_button
+border-radius(4px)
div.comments
- display: block
+ display: none
+comments
clear: both
.add
View
@@ -19,7 +19,7 @@ class Task < ActiveRecord::Base
belongs_to :user
belongs_to :party
- has_many :comments
+ has_many :comments, :dependent => :destroy
validates :user_id, :content, :presence => true
@@ -1,2 +1,3 @@
+$('#<%= dom_id(@comment.task) %> span.comments').html("<%= @comment.task.comments.count %>")
$('#<%= dom_id(@comment.task) %> textarea').val("")
$('#<%= dom_id(@comment.task) %> .comments ul').prepend("<%= j(render @comment) %>").fadeIn()
@@ -1 +1,2 @@
-$('#<%= dom_id(@comment) %>').remove().fadeOut()
+$('#<%= dom_id(@comment) %>').remove().fadeOut()
+$('#<%= dom_id(@comment.task) %> span.comments').html("<%= @comment.task.comments.count %>")
@@ -13,8 +13,8 @@
= text_area_tag :content, nil, :rows => 3, :cols => 15, :id => "new_comment_#{dom_id(task)}"
= submit_tag "new comment"
%p
- %span.comments
- 0
+ %span.comments{"data-id" => dom_id(task)}
+ = task.comments.count
= nl2br task.content
- if task.state == "done"
View
@@ -5,3 +5,11 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
+
+(1..5).each do |i|
+ User.create!(name: "Guest#{i}", email: "guest#{i}@example.com", password: "testtest")
+end
+
+(1..3).each do |i|
+ Party.create!(name: "Party#{i}", user_id: rand(5)+1)
+end

0 comments on commit 1af0ae1

Please sign in to comment.