Switch flag/unflag buttons on use via ajax

This commit is contained in:
Carlos Ruiz
2017-09-18 19:07:18 +02:00
parent 8cae97d98d
commit 12d34a3ea1
4 changed files with 10 additions and 2 deletions

View File

@@ -60,6 +60,7 @@
//= require legislation_annotatable //= require legislation_annotatable
//= require watch_form_changes //= require watch_form_changes
//= require followable //= require followable
//= require flagable
//= require documentable //= require documentable
//= require tree_navigator //= require tree_navigator
//= require custom //= require custom

View File

@@ -0,0 +1,4 @@
App.Flagable =
update: (proposal_id, button) ->
$("#" + proposal_id + " .js-flag-actions-container").html(button).foundation()

View File

@@ -1 +1,2 @@
$("#<%= dom_id(@proposal) %> .js-flag-actions").html('<%= j render("proposals/flag_actions", proposal: @proposal) %>'); App.Flagable.update("<%= dom_id(@proposal) %>",
"<%= j render("proposals/flag_actions", proposal: @proposal) %>")

View File

@@ -59,7 +59,9 @@
<% if current_user %> <% if current_user %>
<span class="bullet">&nbsp;&bull;&nbsp;</span> <span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= render 'proposals/flag_actions', proposal: @proposal %> <span class="js-flag-actions-container">
<%= render 'proposals/flag_actions', proposal: @proposal %>
</span>
<% end %> <% end %>
</div> </div>