How to add a dynamic value for a tag's id attribute

how to add a dynamic value for a tag’s id attribute in the ajax
call.For example:several “

” and
“<%=link_to_remote(“MoreInfo”,:update=>”#{product.id}",:url=>{:action=>“more_info”,:id=>product},:method=>:get)-%>"in
a page,i want every ajax result to replace its own “”,instead of the same
one.
so how to add a dynamic value for a tag’s id attribute

Guo Y. wrote:

how to add a dynamic value for a tag’s id attribute in the ajax
call.For example:several “<td id=”#{product.id}" colspan=“4”

Just a note that’s an illegal ID. In summary, an HTML ID attribute must
be
unique to its page, and must satisfy naming conventions commonly
ascribed to
language variables, such as JavaScript variables. An ID may not contain
punctuation or start with a number.

Always go id=“product_<%= product.id %>”, and also think about making
the
product_ prefix more context-specific.

align=“center”>" and

<%=link_to_remote(“MoreInfo”,:update=>”#{product.id}",
:url=>{:action=>“more_info”,:id=>product},:method=>:get)-%>"in

:id => product.id

You might be passing the whole product by copy there. I’m not sure what
it will
turn into!

a page,i want every ajax result to replace its own “”,instead of the same
one.

Put the useful prefix on the id.

Next, think about handling the Ajax call with render :update do … and
put
inside that an update_html directed at that id.


Phlip

Thank you Phlip.But i also want to ask you how to make an ajax call to
bring out an some size window when click a link.Just tell me the outline
instead of detail about how to.Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs