asecondwill
Joined 4/9/2018
asecondwill said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
Thanks for this video.  I'm finding Trix really hard to get my head around and this is a big help. 

Is Rails UJS / Rails.ajax still the way to go with Rails 7?  (although seems to work fine)

asecondwill said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
I've noticed that if i have two actiontext fields on the same page, the embed dialog stops working.  Is that because of use of document rather than this when finding elements? 

asecondwill said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
I think it's because when you do things like 

document.querySelector('[data-trix-action="embed"]').addEventListener("click", event => {

It is setting that on the whole document, not just elements within the controller, right? 

So need to replace 
document.
With something more specific.  Any hints what?   this.element does take querySelector

asecondwill said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
In case anybody else wanting more than one editor on the page, this is how I got it working:

https://stackoverflow.com/questions/70837739/dynamicly-add-a-button-that-is-linked-to-an-action/70849603#70849603

asecondwill said almost 3 years ago on Embedding Youtube Videos into Action Text with Stimulus :
For some attachments, It would be great to add attributes that don't change.  The text in a link for example or a class on an image attachment. 

Is that possible to do ?

Something like this:

  const attachment = new Trix.Attachment({content, sgid})
  attachment.setAttributes(link_text: link_text, link_class: 'a-class')

And then have access to the attributes in the rendering partial for that Model.