In the example in the previous post, notice the syntax that is used to specify key & value for data-toggle
2 ways:
(from http://stackoverflow.com/questions/2134702/ruby-1-9-hash-with-a-dash-in-a-key )
(I). "data-toggle" => 'modal'
<%= link_to " Change Image", "#modalDiv1", { class: 'icon-picture', "data-toggle" => 'modal' } %>
i.e.
1. use double quotes (i.e. string instead of symbol)
2. use hash-rocket syntax (=>) instead of colon (:) syntax
It seems we cannot use the new colon syntax with keys that contain a hyphen (-) as in data-toggle
(II). data: { toggle: 'modal' }
<%= link_to " Change Image", "#modalDiv1", { class: 'icon-picture', data: { toggle:'modal'} }%>
i.e.
1. Specify a 'data' hash for 'data' attributes:
2 ways:
(from http://stackoverflow.com/questions/2134702/ruby-1-9-hash-with-a-dash-in-a-key )
(I). "data-toggle" => 'modal'
<%= link_to " Change Image", "#modalDiv1", { class: 'icon-picture', "data-toggle" => 'modal' } %>
i.e.
1. use double quotes (i.e. string instead of symbol)
2. use hash-rocket syntax (=>) instead of colon (:) syntax
It seems we cannot use the new colon syntax with keys that contain a hyphen (-) as in data-toggle
(II). data: { toggle: 'modal' }
<%= link_to " Change Image", "#modalDiv1", { class: 'icon-picture', data: { toggle:'modal'} }%>
i.e.
1. Specify a 'data' hash for 'data' attributes:
No comments:
Post a Comment