Skip to content
Snippets Groups Projects
Commit 40295ae3 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

loading dynamic content for collections popovers

parent 24c530d2
No related branches found
No related tags found
No related merge requests found
$ ->
$('.default_btn').toggleClass 'active_btn'
$('.add_to_collection').popover
html: true,
container: 'body',
html: true
container: 'body'
content: ->
$('#collections_list_popover').html()
url = $(this).data('poload')
$.get url, (d) ->
$.parseJSON d
return
return
$ ->
$('.add_to_collection').on 'click', (e) ->
$('.add_to_collection').removeClass 'active'
$('.add_to_collection').not(this).popover 'hide'
return
$ ->
# Rails creates this event, when the link_to(remote: true) successfully executes
# The `data` parameter is the decoded JSON object
$(document).on 'ajax:success', 'a.vote', (status, data, xhr)->
$(".votes-count[data-id='#{data.id}']").text data.count
return
$(document).on 'ajax:success', 'a.vote', (status, data, xhr) ->
$('.votes-count[data-id=\'' + data.id + '\']').text data.count
return
\ No newline at end of file
......@@ -11,10 +11,6 @@
<body <%= yield(:body_attributes) %>>
<%= render 'shared/application/header' %>
<% if user_signed_in? %>
<%= render 'learning_objects/add_to_collection_popover', collections: @user_collections %>
<% end %>
<div class="container">
<% if notice %>
<div class="alert alert-info" role="alert">
......
<div class="learning-object-actions">
<%= render 'learning_objects/like_button', learning_object: learning_object %>
<%= render 'learning_objects/bookmarks_button' %>
<%= render 'learning_objects/collections_button' %>
</div>
\ No newline at end of file
<%= render 'learning_objects/collections_button', learning_object: learning_object %>
</div>
<% if user_signed_in? %>
<%= render 'learning_objects/add_to_collection_popover', collections: @user_collections, learning_object: learning_object %>
<% end %>
\ No newline at end of file
<div id="collections_list_popover">
<div id="collections_list_popover-<%= learning_object.id %>">
<% if collections.empty? %>
<%= link_to 'Criar coleção', me_users_path %>
<% else %>
<ul>
<% collections.each do |collection| %>
<li>
<%= link_to collection.name, add_collection_learning_object_collection(id: collection.id, learning_object_id: learning_object.id), class: 'default_btn', method: :post, remote: true %>
<%= link_to collection.name, add_learning_object_collection(id: collection.id, learning_object_id: learning_object.id), class: 'default_btn', method: :post, remote: true %>
</li>
<% end %>
</ul>
......
<button type="button" class="btn btn-default btn-xs add_to_collection" data-toggle="button" aria-pressed="false" autocomplete="off" title="Adicionar as coleções">
<button type="button" class="btn btn-default btn-xs add_to_collection" data-poload="/learning_objects/<%= learning_object.id %>/collections.json" data-toggle="button" aria-pressed="false" autocomplete="off" title="Adicionar as coleções">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span>
</button>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment