| suggest: function( | query, | | callback | ) |
|
Basic Example
var service = new EMS.Service.Suggest();
service.suggest("Mel", function(response, status) {
if (status == EMS.Status.OK) {
for (var i = 0; i < response.suggestions.length; i++) {
// Do something with the response
var text = response.suggestions[i].text;
var id = response.suggestions[i].id;
}
} else {
// Error status
alert(response.message);
}
});
Complex Example
var query = {
text: "Be", // Actual text to search for
size: 10, // Maximum number of items to get back
granularity: [EMS.Granularity.SUBURB, // Array of the types of items to return
EMS.Granularity.REGION]
}
service.suggest(query, function(response, status) {
if (status == EMS.Status.OK) {
for (var i = 0; i < response.suggestions.length; i++) {
// Do something with the response
var text = response.suggestions[i].text;
var id = response.suggestions[i].id;
}
} else {
// Error status
alert(response.message);
}
});
Parameters
| query | {Mixed} is either a {String} or a query as an {Object} is actual item to find. |
| callback | {Function} is the callback function in the form function(result, status). |