Frage

Is there any shortcut for:

link_to 'title', path, 'data-type' => :html

I thought :type=>:html would work, much as :remote=>true transforms to data-remote='true', but not supported.

War es hilfreich?

Lösung

Yes:

link_to 'title', path, data: { type: :html }

small edit

It comes from the tag helper: http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-tag

Its maybe not a shortcut in your case but can be very handy if you have to set multiple data-attributes:

link_to 'title', path, data: { first_name: @user.first_name, 
                               last_name:  @user.last_name,
                               # etc. }

But no, no type: :html, sorry...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top