Hi James...
Well-- after a lot of experimentation, the solution I came up with was
this: (and mind you it is far from elegant)
Inside the attribute_fu 's associated_form_helper.rb, I added an
additional page << "fix_attribute_fu():"
@template.link_to_function name do |page|
page << "if (typeof #{variable} == 'undefined') #{variable} =
0;"
page << "new Insertion.Bottom('#{container}', new
Template("+form_builder.render_associated_form(object, :fields_for =>
{ :javascript => true }, :partial => partial).to_json
+").evaluate({'number': --#{variable}}))"
page << "fix_attribute_fu();"
end
....
Then in my application.js file, I put all of my model's column names
into an array, and set a disc_id variable...
form_name_list = new
Array("menuadn_id","vendor_id","designer_id","wts_id","team_id","wave","sku ","textless","transemail","casting","transreceived","menupreapprove","menua pprove","dueauthoring","etaauthoring","approvemenu","shipimage");
form_id_header = "release_disc_attributes__new__";
disc_id = 0;
function fix_attribute_fu() {
disc_id ++;
for (f = 0; f < form_name_list.length; f++) {
var id_to_get = form_id_header+"__number__"+form_name_list[f];
form_element = $(id_to_get)
form_element.value = today;
previous_form_element = previousHTMLElementSibling(form_element);
new_id = form_id_header+"__fixed"+disc_id+"_"+form_name_list[f];
previous_form_element.htmlFor = new_id;
form_element.id = new_id;
}
}
function previousHTMLElementSibling(n) { while (n = n.previousSibling)
{ if (n.nodeType == 1) break; } return n; };
.. and this gives me outputted source like:
<li>
<label for="release_disc_attributes__new____fixed2_sku">SKU locked:</
label>
<input id="release_disc_attributes__new____fixed2_sku"
name="release[disc_attributes][new][-2][sku]" size="8" type="text">
</li>
...
I know this approach is probably less than ideal, but it was the best
I could come up with... Anyway, everything works great, and I can
grab elements by id freely...
-patrick
On Jun 19, 6:18 am, "James Golick" <jamesgol...@gmail.com> wrote:
> yeah, I konw about this issue.
> I just wasn't sure how to solve it, and it wasn't causing anybody any
> trouble, so I left it in.
> Any ideas?
> On Thu, Jun 19, 2008 at 4:50 AM, patrick <patrick99...@gmail.com> wrote:
> > Looking at the generated source:
> > <input
> > id="project_release_attributes__new__0__disc_attributes__new____number__cas ting"
> > name="project[release_attributes][new][0][disc_attributes][new][-1]
> > [casting]" size="8" type="text">
> > The id and name do not match (the ID is missing the -1).. In fact all
> > of the partials added after the first have the same id... Is this
> > right?
> > -patrick