按照下面的教程,我正在使用 Stimulus 和 ActionText 來處理“提及”;
使用 ActionText 的用戶 @提及
顯示 actiontext 內容時,每個“提及”的部分內容都是從 json.builder 檔案呈現的。
我遇到的問題是 actiontext 內容在 turbo 框架內,并且提及部分包含一個鏈接。因此我需要添加以下屬性來轉義渦輪幀:
"data-turbo-frame": "_top"
由于某種原因,此屬性在渲染時被從頁面中剝離。(使用 html.slim)。
= link_to character.name, character_path(character), "data-turbo-frame": "_top", class: "font-semibold #{character.color} mention hover-trigger"
結果 HTML:
<a class="font-semibold text-pink-700 mention hover-trigger" href="/characters/1">Example Character Name</a>
uj5u.com熱心網友回復:
ActionText 會去除未列入白名單的標簽和 html 屬性,包括“style”和“data-turbo-frame”屬性。為了防止特定屬性出現這種情況,請將以下內容添加到初始化程式中,例如config/initializers/action_text.rb。
ActionText::Attachment::ATTRIBUTES << 'data-turbo-frame'
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/406646.html
標籤:
