Quantcast
Channel: Best way to use html5 data attributes with rails content_tag helper? - Stack Overflow
Browsing all 7 articles
Browse latest View live

Answer by coisnepe for Best way to use html5 data attributes with rails...

Building on previous answers, here's the canonical way to do it now:content_tag(:div, "Some Text", id: "foo", data: { attr: some_variable })content_tag(:div, "Some Text", id: "foo", data: {...

View Article



Answer by coloradoblue for Best way to use html5 data attributes with rails...

JQuery Air (codeschool.com) Level 1, Example 1Codeschool/platform-independent version<section id="tabs"><ul><li><a href="#2012-09-27" data-flights="6">Sep...

View Article

Answer by stephencelis for Best way to use html5 data attributes with rails...

Rails 3.1 ships with built-in helpers:http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-tagE.g.,tag("div", :data => {:name => 'Stephen', :city_state => %w(Chicago...

View Article

Answer by Cory Schires for Best way to use html5 data attributes with rails...

A helper's not a bad idea but seems a bit of an overkill for what's essentially me being fusy about syntax. I suppose there's nothing built into rails which is what I was hoping for. I'll just use...

View Article

Answer by rodrigob for Best way to use html5 data attributes with rails...

You can always create you own helper function so then you can write<%= div_data_tag the_id, some_text, some_data %>

View Article


Answer by Eimantas for Best way to use html5 data attributes with rails...

Have you tried using quotes with symbol? Something like::"data-foo" => :bar

View Article

Best way to use html5 data attributes with rails content_tag helper?

The issue, of course, is that ruby symbols don't like hyphens. So something like this obviously won't work:content_tag(:div, "Some Text", :id => "foo", :data-data_attr => some_variable)One option...

View Article
Browsing all 7 articles
Browse latest View live




Latest Images