Initialise user autocomplete element using data from element itself rather than AJAX request

This commit is contained in:
Rob H
2014-08-30 01:21:35 +10:00
parent 13d814ff23
commit e106c7a0cd
2 changed files with 3 additions and 3 deletions

View File

@@ -4,8 +4,7 @@ angular.module("admin.users").directive "ofnUserAutocomplete", ($http) ->
element.select2
multiple: false
initSelection: (element, callback) ->
$http.get( Spree.url(Spree.routes.user_search, { ids: element.val() }) ).success (data) ->
callback(data[0]) if data.length > 0
callback { id: element.val(), email: attrs.email }
ajax:
url: Spree.routes.user_search
datatype: 'json'

View File

@@ -27,7 +27,8 @@
.with-tip{'data-powertip' => "The primary user responsible for this enterprise."}
%a What's this?
.eight.columns
= f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true
- owner_email = @enterprise.andand.owner.andand.email || ""
= f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true, email: owner_email
.row
.three.columns.alpha