lib/jqr-helpers/helpers.rb in jqr-helpers-1.0.55 vs lib/jqr-helpers/helpers.rb in jqr-helpers-1.0.56

- old
+ new

@@ -388,14 +388,19 @@ # Add a link which toggles the visibility of a separate element. The link # element itself will be given the class "ujs-toggle-open" and # "ujs-toggle-closed" so you can style it. # @param body [String] the text for the link. # @param id [String] the ID of the element to toggle. - # @param options [Hash] HTML options for the link. + # @param options [Hash] HTML options for the link. An extra option is + # start_open which indicates that the content to toggle is already + # visible. def link_to_toggle(body, id, options={}) tag_name = options.delete(:tag_name) || :a options[:class] ||= '' - options[:class] << ' ujs-toggle ujs-toggle-closed' + options[:class] << ' ujs-toggle' + options[:class] << (options.delete(:start_open) ? + ' ujs-toggle-open' : + ' ujs-toggle-closed') content_tag tag_name, body, options.merge(:'data-id' => id) end # Add a button which toggles the visibility of a separate element. # @param body [String] the text for the button.