@@ -135,7 +135,7 @@ def print_button_to(link, options = {})
135135 # Generic Submit button for a form
136136 def submit_button ( options = { } , data = { } )
137137 disable_text = options [ :disable_text ] || "Saving"
138- _button_to ( { text : "Save" , icon : "floppy-o" , type : "success" , align : "pull-right" } . merge ( options ) , data : { disable_with : disable_text } . merge ( data ) , name : options [ :name ] || 'button' )
138+ _button_to ( { text : "Save" , icon : "floppy-o" , type : "success" , align : "pull-right" } . merge ( options ) , data : { turbo_submits_with : disable_text } . merge ( data ) , name : options [ :name ] || 'button' )
139139 end
140140
141141 # Like above, but POSTs to a URL instead of to a form
@@ -162,8 +162,11 @@ def _link_to(link, options = {}, properties = {})
162162 text = options [ :text ]
163163 size = options [ :size ]
164164 type = options [ :type ]
165+
166+ properties [ :data ] ||= { }
167+ properties [ :data ] [ :disable_with ] ||= "Please wait..."
168+
165169 if options [ :data ] . present?
166- properties [ :data ] ||= { }
167170 properties [ :data ] . merge! ( options [ :data ] )
168171 end
169172 properties [ :title ] = options [ :title ] if options [ :title ] . present?
@@ -180,7 +183,7 @@ def _link_to(link, options = {}, properties = {})
180183 end
181184 end
182185
183- def _button_to ( options = { } , other_properties = { } )
186+ def _button_to ( options = { } , properties = { } )
184187 submit_type = options [ :submit_type ] || "submit"
185188 id = options [ :id ]
186189 type = options [ :type ]
@@ -189,7 +192,10 @@ def _button_to(options = {}, other_properties = {})
189192 text = options [ :text ]
190193 align = options [ :align ]
191194
192- button_tag ( { type : submit_type , id : id , class : "btn btn-#{ type } btn-#{ size } #{ align } " } . merge ( other_properties ) ) do
195+ properties [ :data ] ||= { }
196+ properties [ :data ] [ :turbo_submits_with ] ||= "Please wait..."
197+
198+ button_tag ( { type : submit_type , id : id , class : "btn btn-#{ type } btn-#{ size } #{ align } " } . merge ( properties ) ) do
193199 fa_icon icon , text : text
194200 end
195201 end
0 commit comments