got autocomplete presented correctly

This commit is contained in:
Henry Oswald 2014-06-13 17:17:58 +01:00
parent b9afde591b
commit 09f5a67f9b
2 changed files with 16 additions and 3 deletions

View file

@ -124,7 +124,13 @@ block content
.input .input
input(type='text', name='last_name', ng-model="userInfoForm.last_name", ng-blur="sendUpdate()", placeholder='Last Name') input(type='text', name='last_name', ng-model="userInfoForm.last_name", ng-blur="sendUpdate()", placeholder='Last Name')
.input .input
input(type='text', name='institution', ng-model="userInfoForm.institution", placeholder='Institution', ng-blur="sendUpdate()") input(type='text', name='institution', ng-model="userInfoForm.institution", placeholder='Institution', ng-blur="sendUpdate()", ng-keyup="updateInstitutionsList()", list="_institutions")
datalist#_institutions
option(ng-repeat='institution in institutions') {{institution.name}}
.input .input
input(type='text', name='role', ng-model="userInfoForm.role", placeholder='Role', ng-blur="sendUpdate()") input(type='text', name='role', ng-model="userInfoForm.role", placeholder='Role', ng-blur="sendUpdate()")
.span3 .span3

View file

@ -1,9 +1,12 @@
define ["libs/angular"], (a)-> define ["libs/algolia", "libs/typeahead", "libs/angular"], (algolia)->
app = angular.module("userProfileInformationApp", []) app = angular.module("userProfileInformationApp", [])
app.controller "UpdateForm", ($scope, $http)-> app.factory "Institutions", ->
new AlgoliaSearch("SK53GL4JLY", "75dc5e65794cd47eb7f725e6bb5075be").initIndex("institutions")
app.controller "UpdateForm", ($scope, $http, Institutions)->
$scope.institutions =
$scope.hidePersonalInfoSection = true $scope.hidePersonalInfoSection = true
$http.get("/user/personal_info").success (data)-> $http.get("/user/personal_info").success (data)->
@ -30,5 +33,9 @@ define ["libs/angular"], (a)->
results = _.filter $scope.userInfoForm, (value)-> value? and value?.length != 0 results = _.filter $scope.userInfoForm, (value)-> value? and value?.length != 0
results.length * 20 results.length * 20
$scope.updateInstitutionsList = ->
Institutions.search $scope.userInfoForm.institution, (err, response)->
$scope.institutions = response.hits
angular.bootstrap(document.getElementById("userProfileInformation"), ['userProfileInformationApp']) angular.bootstrap(document.getElementById("userProfileInformation"), ['userProfileInformationApp'])