2,530 Experience
25 Lessons Completed
0 Questions Solved


Thanks @excid3, very neat :-) One comment though, as capturing scroll events like this is usually quite CPU-intensive, wouldn't it be better to use an IntersectionObserver? (https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver)

also see: https://m.signalvnoise.com/how-to-back-to-top-button-without-scroll-events/

Posted in Stimulus JS Twitter UI: Part 1 Discussion

Hi Chris,

great video!

One thing I like to do these days is, instead of responding with a create.js.erb, catch the ajax:success event in the stimulus controller (possibly even by attaching it to document: https://stimulusjs.org/reference/actions#global-events).

You don't get inline rendering of your Rails ivar this way, but you stay in the context of your controller and don't have to use that kind of "hacky" way of updating the form/character count, since you have access to this.element and your targets...

I built that w/ActionCable just last week. Should I write up a blog post?

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.