Greetings, this trigger works correctly ONE time. If it fires again, it just refreshes my page, so I’m guessing that the preventDefault isn’t working. Am I missing something?
function watchForm() {
$(‘form’).submit(event => { //listening for event on the pop-up menu
event.preventDefault(); //suppresses browser from going to a linked page (that isnt reall linked) so this page can be updated.
$(’#js-error-message’).empty();
let searchState = $(’#js-stateMenuForm :selected’).val(); //invoked state code value stored in searchState
getParks(searchState); //calls getParks and sends the state code
});
}
Hmm, try using event.preventDefault(); AND event.stopPropogation();?
OR have you tried returning false at the end of the function instead of the e.preventdefault?
This SO might help with regards to why, (if it fixes).
You need to call watchForm again inside your displayResults function right after you call stateMenu('nav');
You need to empty the div with id=“parks” after the same call to watchForm inside your displayResults function. Otherwise, the results keep getting appended to the end of the section instead of being at the top.