(Quick Reference)

4 Autocomplete - Reference Documentation

Authors: Matouš Kučera

Version: 1.0

4 Autocomplete

JavaScript autocomplete engine is an important part of this plugin. It allows the user to see the recommended countries while he is typing. By default, the jQuery autocomplete is used by the plugin.

4.1 jQuery Autocomplete

jQuery autocomplete is the default autocomplete. Therefore, this plugin depends on jquery-ui plugin.

If you don't want to use this autocomplete and jquery-ui dependency than simply exclude it from BuildConfig.groovy:

compile ':country-selector:0.1' {
   exclude 'jquery-ui'
}

4.2 Twitter Bootstrap Autocomplete

The Twitter Bootstrap Autocomplete is an alternative implemented within the plugin.

You can set this implementation using the resources (Resource Plugin) in ApplicationResources.groovy:

overrides {
   'country-selector-plugin-js' {
      dependsOn 'country-selector-plugin-bootstrap-js'
   }
}

The Twitter Bootstrap country selector is dependent on bootstrap-typeahead therefore Twitter Bootstrap Grails Plugin is required:

plugins {
…
    runtime ':twitter-bootstrap:2.3.2'
…
}

4.3 Custom Autocomplete

Similarly to Twitter Bootstrap Autocomplete you can set your custom autocomplete JavaScript implementation in ApplicationResources.groovy:
'country-selector-plugin-custom-js' {
   dependsOn 'jquery'
   resource url: 'js/application/customCountrySelectorAutocomplete.js', disposition: 'head'
}

overrides { 'country-selector-plugin-js' { dependsOn 'country-selector-plugin-custom-js' } }

The custom JavaScript autocomplete should follow the implementation of Baymard Institute JavaScript country selector (See Github for more details).