Google Groups Home
Help | Sign in
is the add_associated_link supposed to do this?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
patrick  
View profile
 More options Jun 19, 4:50 am
From: patrick <patrick99...@gmail.com>
Date: Thu, 19 Jun 2008 01:50:00 -0700 (PDT)
Subject: is the add_associated_link supposed to do this?
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Golick  
View profile
 More options Jun 19, 9:18 am
From: "James Golick" <jamesgol...@gmail.com>
Date: Thu, 19 Jun 2008 09:18:46 -0400
Local: Thurs, Jun 19 2008 9:18 am
Subject: Re: is the add_associated_link supposed to do this?

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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
patrick  
View profile
 More options Jul 9, 6:57 am
From: patrick <patrick99...@gmail.com>
Date: Wed, 9 Jul 2008 03:57:01 -0700 (PDT)
Local: Wed, Jul 9 2008 6:57 am
Subject: Re: is the add_associated_link supposed to do this?
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google