Changeset 94574 in spip-zone
- Timestamp:
- Jan 13, 2016, 2:39:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/codes_postaux/trunk/javascript/codes_postaux.js
r94573 r94574 1 2 1 function codes_postaux_split( val ) { 3 2 return val.split( /,\s*/ ); … … 8 7 } 9 8 10 11 9 function codes_postaux_autocomplete(objet){ 12 10 13 $(objet).after('<input type="hidden" id="id_code_postal" name="id_code_postal" value="" />') 14 $(objet).autocomplete( 15 { 16 source: function( request, response ) { 17 $.getJSON( code_postal_url, { 18 term: codes_postaux_extractLast( request.term ) 19 }, response ); 20 }, 21 search: function() { 22 // custom minLength 23 var term = codes_postaux_extractLast( this.value ); 24 if ( term.length < 2 ) { 11 $(objet).after('<input type="hidden" id="id_code_postal" name="id_code_postal" value="" />'); 12 $(objet).autocomplete( 13 { 14 source: function( request, response ) { 15 $.getJSON( code_postal_url, { 16 term: codes_postaux_extractLast( request.term ) 17 }, response ); 18 }, 19 search: function() { 20 // custom minLength 21 var term = codes_postaux_extractLast( this.value ); 22 if ( term.length < 2 ) { 23 return false; 24 } 25 }, 26 focus: function( event, ui ) { 27 $( "#id_code_postal" ).val( ui.item.id ); 28 return false; 29 }, 30 31 select: function( event, ui ) { 32 $('#id_code_postal').val(ui.item.id); 33 this.value = ui.item.label; 25 34 return false; 26 35 } 27 }, 28 focus: function( event, ui ) { 29 console.log(ui) 30 $( "#id_code_postal" ).val( ui.item.id ); 31 return false; 32 }, 33 34 select: function( event, ui ) { 35 console.log(ui) 36 $('#id_code_postal').val(ui.item.id) 37 this.value = ui.item.label; 38 return false; 39 } 40 }) 41 .data("ui-autocomplete")._renderItem = function (ul, item) { 42 return $("<li>") 43 .data("ui-autocomplete-item", item) 44 .append("<a>" + item.label + " " + item.ville + "</a>") 45 .appendTo(ul); 46 } 47 48 49 50 36 }) 37 .data("ui-autocomplete")._renderItem = function (ul, item) { 38 return $("<li>") 39 .data("ui-autocomplete-item", item) 40 .append("<a>" + item.label + " " + item.ville + "</a>") 41 .appendTo(ul); 42 }; 51 43 } 52
Note: See TracChangeset
for help on using the changeset viewer.