Skip to content

Instantly share code, notes, and snippets.

@hugomaiavieira
Created October 3, 2014 14:50
Show Gist options
  • Select an option

  • Save hugomaiavieira/2ab60400e58d88fbf0b4 to your computer and use it in GitHub Desktop.

Select an option

Save hugomaiavieira/2ab60400e58d88fbf0b4 to your computer and use it in GitHub Desktop.
select2
def insert_select2(team_name = nil)
# When it simulates an existing record, id is passed, and controller take it by id.
# It's simulating Select2 request for getting record on the query.
# When name is passed, it indicates that no record was found, creating a new one.
# This behavior is implemented on SalespointController#create.
execute_script("$('#app-team-modal .select2-focusser').val('#{team_name}').trigger('keyup')");
find('.select2-chosen').click
sleep 2
find('.select2-results li:first-child').click
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment