jquery-ui-rails-helpers icon indicating copy to clipboard operation
jquery-ui-rails-helpers copied to clipboard

Dom id's generation (to prevent strange behavior....)

Open elmatou opened this issue 15 years ago • 1 comments

Hi people, When I set several instances of helpers (Tabs or Accordions) in a single view, I have to choose a lot of tab or accordion dom id's. a.create("dom1", "apple") do.... a.create("dom2", "pear") do.... a.create("dom3", "fish") do.... I think it is not in the scope of users (coders) to choose these id's (deeply nested in the views). I see as an enhancement the patch below, which use the container id in order to generate other's id. accordions_for :id => :my_accordion do |a| a.create("apple") do.... a.create("pear") do.... a.create("fish") do....

I'm aware, it should break some backward compatibilities (in order to be fully useful). It should also be mandatory to provide thee container id (anyway you need to set it for the jQuery part if the code).

elmatou avatar Nov 16 '10 17:11 elmatou

   def create( accordion_text, options={}, &block )
      raise "Block needed for AccordionsRenderer#CREATE" unless block_given?
     @accordions << [ @options[:id].to_s + "_" + @accordions.count.to_s,    accordion_text, options, block ]
    end

elmatou avatar Nov 16 '10 18:11 elmatou