1. Conclusion </ b>
2. How to use </ b>
3. Why didn't you write to the js file </ b>
4. What I learned from here </ b>
In any html.erb
<script> . . . </script>
In conclusion, it didn't read the js file, or it didn't read unless I reloaded it once. As for the content, the password was displayed and hidden, but since it appears a lot when searching, I will omit it here.
Rails6.0 Vscode using.
require("@rails/ujs").start() require("turbolinks").start() require("@rails/activestorage").start() require("channels") require("./security") #➡︎ Applicable file
Since it is described, I thought that the js file should be applied, but it was not reflected at all.
Also, I programmed the display / non-display of the password in the js file, but there was no response, so I referred to it in various ways. The following programs are listed first.
I was able to show and hide the password, but it was not reflected until I pressed reload once. So I haven't solved the js file problem, but I'm okay because I was able to do what I wanted to do for the time being. (Readability is not good)
" I examined the processing around DOMContentLoaded in detail "
"[JS] Please tell me why addEventListener does not work"
" Difference between DOMContentLoaded event and load event [Timing] "