Skip to content

Commit

Permalink
dropdown works
Browse files Browse the repository at this point in the history
  • Loading branch information
ingridh authored and zhangaaron committed Apr 17, 2015
1 parent 40d9b59 commit cc12aee
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
19 changes: 0 additions & 19 deletions app/assets/javascripts/problems.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,6 @@
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$(document).ready ->
$('.dropdown-menu input, .dropdown-menu label').click (event) ->
event.stopPropagation()

$('.dropdown-menu input').change (event) ->
$btnGroup = $(this).closest(".btn-group")
$menuItems = $btnGroup.find(".dropdown-menu input:checked")
selected = []
$menuItems.each (index, item) ->
selected.push($(item).val())
title = ""
if selected.length > 0
title = selected.join(", ")
else
title = "Please select"

$btnGroup.find(".btn").text(title)


@myfunction = (problemid, collectionid) ->
$.ajax({url: "/add_problem?collection_id=#{collectionid}&id=#{problemid}"}).done (data) ->
if data["status"] == true
Expand Down
4 changes: 1 addition & 3 deletions app/views/shared/_problems_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
-if problems_index
/ =link_to "add to #{Collection.find(@current_user.current_collection).name} (current)", add_problem_path(:id => problem.id, :collection_id => @current_user.current_collection), {:id => "problem_#{problem.id}"}
/ %a{:class => "addlink", :id => "problem#{problem.id}", :onclick => "myfunction('#{problem.id}', #{@current_user..topbar-wrapper{:style => "z-index: 5;"}
= select_tag "dropdown", options_from_collection_for_select(Collection.all, "id", "name"), :onchange => "myfunction(id, '2')"


= select_tag "dropdown", options_from_collection_for_select(Collection.all, "id","name"), :onchange => "myfunction(#{problem.id}, this.value)"
-else
=link_to "remove from this collection", remove_problem_path( :id => problem.id, :collection_id => collection), {:id => "problem_#{problem.id}"}

0 comments on commit cc12aee

Please sign in to comment.