Commit 85bd43472dd428ee8ad449b9065e0fbfbb91dd82
Committed by
Fabio Teixeira
1 parent
1a51c6d2
Exists in
master
and in
79 other branches
Transforming the city field in auto complete.
- To use it, you first need to provide the state. Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
2 changed files
with
23 additions
and
1 deletions
Show diff stats
public/views/create-institution.js
@@ -239,6 +239,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -239,6 +239,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
239 | cnpj.hide(); | 239 | cnpj.hide(); |
240 | city.hide(); | 240 | city.hide(); |
241 | state.hide(); | 241 | state.hide(); |
242 | + autocomplete_city(); | ||
242 | } else { | 243 | } else { |
243 | cnpj.show(); | 244 | cnpj.show(); |
244 | city.show(); | 245 | city.show(); |
@@ -246,11 +247,32 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -246,11 +247,32 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
246 | } | 247 | } |
247 | } | 248 | } |
248 | 249 | ||
250 | + function autocomplete_city(){ | ||
251 | + $('#city_field').autocomplete({ | ||
252 | + source : function(request, response){ | ||
253 | + $.ajax({ | ||
254 | + type: "GET", | ||
255 | + url: '/account/search_cities', | ||
256 | + data: {city_name: request.term, state_name: $("#community_state").val()}, | ||
257 | + success: function(result){ | ||
258 | + response(result); | ||
259 | + }, | ||
260 | + error: function(ajax, stat, errorThrown) { | ||
261 | + console.log('Link not found : ' + errorThrown); | ||
262 | + } | ||
263 | + }); | ||
264 | + }, | ||
265 | + | ||
266 | + minLength: 3 | ||
267 | + }); | ||
268 | + } | ||
269 | + | ||
249 | 270 | ||
250 | function institution_type_actions(type) { | 271 | function institution_type_actions(type) { |
251 | var country = $("#community_country").val(); | 272 | var country = $("#community_country").val(); |
252 | if( type === "PublicInstitution" && country == "BR") { | 273 | if( type === "PublicInstitution" && country == "BR") { |
253 | show_public_institutions_fields(); | 274 | show_public_institutions_fields(); |
275 | + autocomplete_city(); | ||
254 | } else { | 276 | } else { |
255 | show_private_institutions_fields(); | 277 | show_private_institutions_fields(); |
256 | } | 278 | } |
views/gov_user_plugin/_institution.html.erb