     do_update(socket, broadcast, attr: "class", set: value, on: selector)
   end
   defp do_update(socket, broadcast, :class, toggle: value, on: selector) do
-    {:ok, do_query(socket, selector, "toggleClass(\"#{value}\")", :update, broadcast)}    
+    {:ok, do_query(socket, selector, {:toggleClass, "(\"#{value}\")"}, :update, broadcast)}    
   end
   defp do_update(socket, broadcast, :class, set: values, on: selector) when is_list(values) do
     # switch classes: updates the attr: "class" string with replacement of class, if it is on the list
-    c = socket |> select(:classes, from: selector)
+    c = socket |> select(attrs: "class", from: selector)
     one_element_selector_only!(c, selector)
-    classes = c |> List.first()
+
+    classes = Map.values(c) |> Enum.map(&String.split/1) |> List.first()
     replaced = Enum.map(classes, fn c -> 
       if c in values do 
         next_in_list(values, c) 


  # returns next value of the given list (cycle) or the first element of the list
  defp next_value(socket, values, method, selector) when is_list(values) do
    v = socket |> select(method, from: selector)
    one_element_selector_only!(v, selector)
    next_in_list(values, v |> List.first())
  end
  defp next_value(_socket, value, _method, _selector), do: value

  defp next_value(socket, values, method, argument, selector) when is_list(values) do
    v = socket |> select([{method, argument}, from: selector]) 
    one_element_selector_only!(v, selector)
    next_in_list(values, v |> List.first())
  end
  defp next_value(_socket, value, _method, _argument, _selector), do: value


  end

  defp jquery_method(method) do
    {method, "()"}
  end
  defp jquery_method(method, value) do
    {method, "(#{escape_value(value)})"}
  end
  defp jquery_method(method, attribute, value) do
    {method, "(#{escape_value(attribute)}, #{escape_value(value)})"}
  end

  #TODO: move it to templates

  defp build_js(selector, {:all, "()"}, :select) do
    #val: $(this).val(), html: $(this).html(), text: $(this).text()
    methods = Enum.map(@methods -- [:all], fn m -> "#{m}: $(this).#{m}()" end) |> Enum.join(", ")
    """
