instance method dom_target

Ruby on Rails 8.1.2

Since v8.1.2

Signature

dom_target(*objects)

The DOM target convention is to concatenate any number of parameters into a string. Records are passed through dom_id, while string and symbols are retained.

dom_target(Post.find(45))                  # => "post_45"
dom_target(Post.find(45), :edit)           # => "post_45_edit"
dom_target(Post.find(45), :edit, :special) # => "post_45_edit_special"
dom_target(Post.find(45), Comment.find(1)) # => "post_45_comment_1"

Parameters

objects rest
Source
# File actionview/lib/action_view/record_identifier.rb, line 111
    def dom_target(*objects)
      objects.map! do |object|
        case object
        when Symbol, String
          object
        when Class
          dom_class(object)
        else
          dom_id(object)
        end
      end
      objects.join(JOIN)
    end

Defined in actionview/lib/action_view/record_identifier.rb line 111 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::RecordIdentifier

Type at least 2 characters to search.

↑↓ navigate · open · esc close