question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Input text is gone when user enters text before JavaScript is downloaded - best practice?

See original GitHub issue

Hey guys, when I’m using FastBoot and user enters text into inputs in my form (BEFORE JAVASCRIPT IS LOADED), and then tries to submit it - Ember empties input elements.

I’d like to ask for best practice how to deal with such situations? Should I show input fields in didInsertElement hooks? Or is it possible to show some kind of spinner before Ember is fully loaded?

Thanks, really appreciate the work which has been done over the years in Ember!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
simonihmigcommented, Dec 12, 2017

FWIW, I was just working on a solution to the same problem. So far I followed this approach:

  1. collect all input values just before the static DOM is destroyed
  2. “rehydrate” the inputs after the first (browser) render, by reassigning the value, and focussing the previously focused input (if any)
  3. render all forms in FastBoot like <form onsubmit="alert('Please wait message'); return false;">, which will prevent form submission until the Ember app has taken over.

I have already prepared this as an in-repo addon, might publish this if it makes sense to you, and after some cleanup/docs etc.

1reaction
simonihmigcommented, Dec 17, 2017

@Kuzirashi Here you go: https://github.com/kaliber5/ember-fastboot-form-rehydration

It’s at an early stage, definitely needs some more love (i.e. tests), but feel free to try it out! It does not cover case 3 mentioned in https://github.com/ember-fastboot/ember-cli-fastboot/issues/560#issuecomment-351093606, as we did that in our app code itself. But might be possible to even integrate that into the addon as well sometime…

Feedback certainly welcome, but let’s move that to its own repo! 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selecting all text in HTML text input when clicked
A better approach is to use a <label> for the label and not the value . You can use JS and CSS to...
Read more >
Handling common JavaScript problems - MDN Web Docs
In the Search packages text field, type "jslint" and press Enter/Return to search for linting-related packages. You should see a package ...
Read more >
JavaScript best practices - W3C Wiki
Writing a best practice article is quite a tricky business. ... which is a compilation of best practices and good advice I've amassed...
Read more >
Chapter 1, Writing Your First JavaScript Program - O'Reilly
In your favorite text editor, open the file hello.html. This file is located in the chapter01 folder in the MM_JAVASCRIPT3E folder you downloaded...
Read more >
Introduction to browser events - The Modern JavaScript Tutorial
For instance, to assign a click handler for an input , we can use onclick ... Add JavaScript to the button to make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found