Ruby on Rails
2
Вклад в тег
<div class="d-block" id="comments-show-columns">
<div id="open_comments" class="mt-4">
<div data-controller="comments">
Загрузка комментариев...
<%= link_to url_for(open: 'true'), class: 'hidden', remote: true, data: {target: "comments.opencomment"} do %>
<% end %>
</div>
</div>
</div>
<% if params[:open] %>
var opening = document.querySelector("#open_comments")
var pagin = document.querySelector("#comments-show-paginator")
pagin.classList.toggle("hidden")
opening.innerHTML = ('<%=j render(partial: "comments/comment", collection: @comments, locals: {full: true}, continue_thread: 10) %>')
<% end %>
import { Controller } from "stimulus";
export default class extends Controller {
static targets = ["opencomment"]
connect() {
setTimeout(() => this.opencommentTarget.click(), 500 )
}
}