class BeefCake.Role extends BeefCake.Base
  @autocomplete = (obj) ->
    obj.chosen
      multiple: true
      width: "100%"
      placeholder_text_multiple: "Enter role name"
      no_results_text: "No role with name"

  @create = (obj) ->
    obj.click (e) ->
      e.preventDefault()
      formData = $("#new_membership_form").serializeArray()
      $.ajax '/beef_cake/memberships.json',
        type: 'POST'
        data: formData
        success: (data, textStatus, jqXHR) ->
          window.location.reload()
        error: (jqXHR, textStatus, errorThrown) ->
          alert("#{jqXHR.responseText}")
