diff --git a/app/models/concerns/turbo/broadcastable.rb b/app/models/concerns/turbo/broadcastable.rb
index 845b7efb..30e328b3 100644
--- a/app/models/concerns/turbo/broadcastable.rb
+++ b/app/models/concerns/turbo/broadcastable.rb
@@ -495,23 +495,23 @@ def broadcast_render_later_to(*streamables, **rendering)
# sends My Clearance
# to the stream named "identity:2:clearances"
# clearance.broadcast_morph_to examiner.identity, :clearances
- def broadcast_morph_to(*streamables, target: broadcast_target_default, **rendering)
- Turbo::StreamsChannel.broadcast_morph_to(*streamables, target: target, **broadcast_rendering_with_defaults(rendering)) unless suppressed_turbo_broadcasts?
+ def broadcast_morph_to(*streamables, **rendering)
+ Turbo::StreamsChannel.broadcast_morph_to(*streamables, target: self, **broadcast_rendering_with_defaults(rendering)) unless suppressed_turbo_broadcasts?
end
# Same as broadcast_morph_to but the designated stream is automatically set to the current model.
- def broadcast_morph(target: broadcast_target_default, **rendering)
- broadcast_morph_to(self, target: target, **rendering)
+ def broadcast_morph(**rendering)
+ broadcast_morph_to(self, target: self, **rendering)
end
# Same as broadcast_morph_to but run asynchronously via a Turbo::Streams::BroadcastJob.
- def broadcast_morph_later_to(*streamables, target: broadcast_target_default, **rendering)
- Turbo::StreamsChannel.broadcast_morph_later_to(*streamables,target: target, **broadcast_rendering_with_defaults(rendering)) unless suppressed_turbo_broadcasts?
+ def broadcast_morph_later_to(*streamables, **rendering)
+ Turbo::StreamsChannel.broadcast_morph_later_to(*streamables, target: self, **broadcast_rendering_with_defaults(rendering)) unless suppressed_turbo_broadcasts?
end
# Same as broadcast_morph_later_to but the designated stream is automatically set to the current model.
def broadcast_morph_later(target: broadcast_target_default, **rendering)
- broadcast_morph_later_to(self, target: target, **rendering)
+ broadcast_morph_later_to self, **rendering
end
private
diff --git a/app/models/turbo/streams/tag_builder.rb b/app/models/turbo/streams/tag_builder.rb
index 99a2aa47..294c4e76 100644
--- a/app/models/turbo/streams/tag_builder.rb
+++ b/app/models/turbo/streams/tag_builder.rb
@@ -228,6 +228,32 @@ def prepend_all(targets, content = nil, **rendering, &block)
action_all :prepend, targets, content, **rendering, &block
end
+ # Morph the target in the dom with either the content passed in or a rendering result determined
+ # by the rendering keyword arguments, the content in the block, or the rendering of the target as a record. Examples:
+ #
+ # <%= turbo_stream.morph "clearance_5", "
Morph the dom target identified by clearance_5
" %>
+ # <%= turbo_stream.morph clearance %>
+ # <%= turbo_stream.morph clearance, partial: "clearances/clearance", locals: { title: "Hello" } %>
+ # <%= turbo_stream.morph "clearance_5" do %>
+ # Morph the dom target identified by clearance_5
+ # <% end %>
+ def morph(target, content = nil, **rendering, &block)
+ action :morph, target, content, **rendering, &block
+ end
+
+ # Morph the targets in the dom with either the content passed in or a rendering result determined
+ # by the rendering keyword arguments, the content in the block, or the rendering of the targets as a record. Examples:
+ #
+ # <%= turbo_stream.morph_all ".clearance_item", "Morph the dom target identified by the class clearance_item
" %>
+ # <%= turbo_stream.morph_all clearance %>
+ # <%= turbo_stream.morph_all clearance, partial: "clearances/clearance", locals: { title: "Hello" } %>
+ # <%= turbo_stream.morph_all ".clearance_item" do %>
+ # Morph the dom target identified by the class clearance_item
+ # <% end %>
+ def morph_all(targets, content = nil, **rendering, &block)
+ action_all :morph, targets, content, **rendering, &block
+ end
+
# Send an action of the type name to target. Options described in the concrete methods.
def action(name, target, content = nil, allow_inferred_rendering: true, **rendering, &block)
template = render_template(target, content, allow_inferred_rendering: allow_inferred_rendering, **rendering, &block)