Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix initSelection for auto loading previously selected single select2…

… attribute

Fixes #3
  • Loading branch information...
commit 37f7264192d802d3283c3bdec69b4cb27c9fc7b3 1 parent d32b3ff
@markedmondson markedmondson authored steveyken committed
View
12 app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb
@@ -44,7 +44,6 @@
@set_option_predicates(base_id, available, column_type)
# Set up Select2 for query input
- query_input.val('')
query_input.select2
placeholder: "Search #{selected.data('ajax-entity')}"
minimumInputLength: 1
@@ -59,6 +58,17 @@
obj
results: (data, page) ->
{results: $.map(data, (text, id) -> {id: id, text: text}) }
+ initSelection: (element, callback) ->
+ id = $(element).val()
+ if (id != "")
+ $.ajax
+ url: selected.data('ajax-url'),
+ type: 'POST',
+ dataType: "json"
+ data: selected.data('ajax-key') + "=" + id
+ .done (data) ->
+ callback(data)
+ true
# Handle columns with options detected from validates :inclusion
else if selected.data('select-options') and Select2?
Please sign in to comment.
Something went wrong with that request. Please try again.