I am working with the Mapbox driving directions plugin, doing my own geocoding from within a rails app and using jQuery to set the value of the #mapbox-directions-origin-input and #mapbox-directions-destination-input form inputs with either addresses or coordinates. When I set the values, nothing happens.
$(document).ready(function(){
$('#mapbox-directions-origin-input').val($('#current_coordinates').text());
$('.leaflet-marker-icon').click(function(){
if($('.leaflet-popup').length > 0){
$('#mapbox-directions-destination-input').val($('.marker-description').text());
}
})
})
However, when I copy and paste the exact same values in, the directions appear. Manually adding a space to the form inputs also helps the plugin retrieve the directions.
I presume there is some sort of keypress event I could trigger to mimic this behavior and get the values to pass through correctly, but I’m having a hard time seeing it in the code. I’m primarily looking here but coming up short: https://github.com/mapbox/mapbox-directions.js/blob/121427f30e096e6e839652b8baa2d7ac6660fad3/src/input_control.js
Does anyone have experience with this?