Setting the Element ID of inserted partials with javascript

Hi,

Lets say I have a form with multiple task elements, for adding tasks
to a project, and a link_to_function which inserts a new task using
page.insert_html :partial
eg:
<div id="tasks">tasks holder</div>
<%= link_to_function "Add Task" do |page|
  page.insert_html :bottom, :tasks, :partial => 'task', :object =>
@task.new
end %>

I know when I do a render collection that each partial has a
partial_name_counter variable eg: task_counter, but when I create a
task using the javascript helper this variable no longer works because
it defaults to 1 (as it was when the partial was rendered into the
javascript query), is there anyway to get the same attribute using
javascript?, or at least set a unique id to each task which is created
using the javascript helper?

Thanks in advance.
-Ivan

If you want that ID in order to remove the newly added task, you can
use Prototype's up function. Please take a look at http://railscasts.com/episodes/74.
Not sure if this is what you are trying to do.

Thats a good idea I'll check it out,

What i am actually doing is using the spry framework to provide
validation on the textfield and unfortunately it has to be applied on
a per id basis, not on all elements of a certain class, so therefor i
need to be able to set a unique id to each task input field or
containing div (as spry can be applied to a div then auto assign to
first input)