Save 36% for Black Friday! Learn more

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Migrating From jQuery to Vanilla Javascript Discussion

If you have an issue with partials, try the new to_attachable_partial_path method.

Reply

Thank you!

Reply

It would be great to have a similar video covering how to add a toolbar button with a dialog so we can add things like a better link selector that chooses pages on our site. Or an image selection dialog.

Reply

Is it possible to add attributes to an attachment that we can get at when rendering the attachment? things like text (for links) and classnames etc. These would stay same if model data changes.

Reply

Can we set the class of the figure element for an attachment in the editor? If not it has attachment-content and is always inline. which looks a bit poor for things like media embeds

Reply

I'm having trouble with saving mentions in the controller. When I do post_params I get

#<ActionController::Parameters {"body"=>"<div><figure data-trix-attachment=\"{&quot;content&quot;:&quot;<span class=\\&quot;mention\\&quot;>\\n  Jon Doe\\n</span>\\n&quot;}\" data-trix-content-type=\"undefined\" class=\"attachment attachment--content\"><span class=\"mention\">\r\n  John Doe\r\n</span>\r\n<figcaption class=\"attachment__caption\"></figcaption></figure> is awesome</div>"} permitted: true>

Then I create the post Post.create kudo_params. And when I do Post.last.body I get

"<div class=\"trix-content\">\n  <div> is awesome</div>\n</div>\n"

Where has the mention gone?, it disappeared and survived just the text. The whole text was @John Doe is awesome. Any help is welcomed!

Reply

Update: the problem was a typo in app/views/users/_user.json.jbuilder, instead of defining sgid I wrote sgsid

Reply

I referenced this screencast on this Trix Github issue where comments disappear if the user mentioned is a link and is clicked. Required a data turbo false tag to be filtered from trix content divs as well as allowing the data turbo false html content to be an allowed_attributes of action text.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,110+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.