i using jquery ui autocomplete. have 2 fields want autocomplete work on. how refactor below can have autocomplete work on 2 fields? know can copy , paste code, know theres better way!
jquery(document).ready(function() { jquery(function() { jquery( "#wpsc_checkout_form_22" ).autocomplete({ source: function( request, response ) { var suburb = jquery("#wpsc_checkout_form_22").val(); jquery.ajax({ url: "../wp-admin/admin-ajax.php", datatype: "json", data: { featureclass: "p", style: "full", maxrows: 12, action: "get_suburb_list", query: suburb, }, success: function( data ) { response( jquery.map( data.locations, function( item ) { return { label: item.location + " " + item.state + " " + item.postcode, value: item.location + " " + item.state + " " + item.postcode } })); } }); }, minlength: 2, select: function( event, ui ) { // }, open: function() { jquery( ).removeclass( "ui-corner-all" ).addclass( "ui-corner-top" ); }, close: function() { jquery( ).removeclass( "ui-corner-top" ).addclass( "ui-corner-all" ); } }); }); });
Comments
Post a Comment