Hotwire Discussion

Reseting disabled buttons for a submitted form using Stimulus

Hey y’all —

Two quick questions, spinning up a Rails 6.1 project to take a look at Rails for the first time since version 4.

Firstly, I walked through the code on the demo project and have not been able to see how DHH has Stimulus reset the disabled property on the button element when adding a message. Is there special magic for this in Stimulus or do I need to use this.element to find the disabled button and reenable?

Secondarily and less importantly, I’ve seen elsewhere mentioned that there a naming convention for stimulus controllers. With the underscore format for both the data tags and the file, it appears to work. This appears to be correct but is it desirable? Is kebab case preferred?

<%= form_with(model: [@goal_statement.goal_set, @goal_statement], 
		data: { controller: "reset_goal_statement_form", 
			action: "turbo:submit-end->reset_goal_statement_form#reset"}) do |form| %>

My stimulus controller is named: