Location.reload()

Before, I write a single word about Javascript, allow me to say one thing, it’s a beast.

Switching gears from Ruby to JS threw me for a loop, but after lots of practice and reading it all started to click. So, speaking of clicking, let’s explore Jav…


This content originally appeared on DEV Community and was authored by Maxine Meurer

Before, I write a single word about Javascript, allow me to say one thing, it's a beast.

Switching gears from Ruby to JS threw me for a loop, but after lots of practice and reading it all started to click. So, speaking of clicking, let's explore Javascript and all that can be done in a single click.

The beastly language was Phase four of Flatiron's curriculum, and with every phase comes a project. I was scrambling just to learn the language in a 2 weeks, and now I had to make a single page application. oof. But, somehow, we managed, and here we are writing this blog post with some Javascript knowledge (that will be expanded upon over time), and a fully completed project.

When creating my first S.P.A (Single Page Application), I encountered setbacks, as most new programmers will when coding, and that's okay! My biggest piece of advice for this, disregarding the language, is to read documentation! Mozilla is what is used for Javascript, and thoroughly explains each and every concept there is. This will save you hours of time and frustration, and unlike some other documentation (I found) Mozilla is easy to read and understand.

Out of all the setbacks, I found that not having my application reload/refresh after I made a submission of some kind was very annoying. The last thing I wanted was for a user to be confused about their submission, or have to manually refresh it after, each time. Upon some googling and research came Location.reload(). This magic method reloads the current URL, similarly to a user manually refreshing the page. Exactly what I needed!

Adding it into your code is simple. Wherever your input or button tags exist, add it in! See the following from my code as an example:

Alt Text

And there you have it! An application that instantly reloads upon submission.


This content originally appeared on DEV Community and was authored by Maxine Meurer


Print Share Comment Cite Upload Translate Updates
APA

Maxine Meurer | Sciencx (2021-05-31T20:08:14+00:00) Location.reload(). Retrieved from https://www.scien.cx/2021/05/31/location-reload/

MLA
" » Location.reload()." Maxine Meurer | Sciencx - Monday May 31, 2021, https://www.scien.cx/2021/05/31/location-reload/
HARVARD
Maxine Meurer | Sciencx Monday May 31, 2021 » Location.reload()., viewed ,<https://www.scien.cx/2021/05/31/location-reload/>
VANCOUVER
Maxine Meurer | Sciencx - » Location.reload(). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/31/location-reload/
CHICAGO
" » Location.reload()." Maxine Meurer | Sciencx - Accessed . https://www.scien.cx/2021/05/31/location-reload/
IEEE
" » Location.reload()." Maxine Meurer | Sciencx [Online]. Available: https://www.scien.cx/2021/05/31/location-reload/. [Accessed: ]
rf:citation
» Location.reload() | Maxine Meurer | Sciencx | https://www.scien.cx/2021/05/31/location-reload/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.