Weather application only runs properly once or after page refresh

The link to the codepen is http://codepen.io/damianocel/pen/BzYbwO

Now, this does not run on codepen for some reason, it will run in a text editor tool with live preview.

Goes like this, input city name, press enter, and the current temp will be displayed.

This works, but only one time, or after a ctr+f5 refresh.

It’s using the simpleWeather.js library, which btw has not very many places as options, but US cities will generally work.

Does anyone know why this is? Is this issue a library issue or my code:-)

$('#where').keypress fires too late and the default action can’t be prevented.

If you use keydown instead event.preventDefault() will do what you are expecting.

Thanks for that, but it did not help, Infact, it does not seem to be working at all, while it did yesterday with the same code. I too believe too that the e.preventDefault is the culprit here.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.