Commit 85bd43472dd428ee8ad449b9065e0fbfbb91dd82
Committed by
Fabio Teixeira
1 parent
1a51c6d2
Exists in
master
and in
3 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 | 239 | cnpj.hide(); |
240 | 240 | city.hide(); |
241 | 241 | state.hide(); |
242 | + autocomplete_city(); | |
242 | 243 | } else { |
243 | 244 | cnpj.show(); |
244 | 245 | city.show(); |
... | ... | @@ -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 | 271 | function institution_type_actions(type) { |
251 | 272 | var country = $("#community_country").val(); |
252 | 273 | if( type === "PublicInstitution" && country == "BR") { |
253 | 274 | show_public_institutions_fields(); |
275 | + autocomplete_city(); | |
254 | 276 | } else { |
255 | 277 | show_private_institutions_fields(); |
256 | 278 | } | ... | ... |