ajax on rails

I need som help i want tha a hole

to have a link to remote to a controllers action (yo do click on any part inside th div and the action is executed) how can i do that!!

Felipe Vergara wrote:

I need som help i want tha a hole <div></div> to have a link to remote to a controllers action (yo do click on any part inside th div and the action is executed) how can i do that!!

Put everything inside the div into a partial. Put the link_to_remote around the partial, like this:

   <%= link_to_remote render(:partial => 'my_partial'), :url => {...} %>

I suspect you'll get an <a> with an entire stretch of HTML inside, not just a string. Report back if the link_to_remote calls h() on the HTML!

i will try that thank yo very much!!

Felipe Vergara wrote:

i will try that thank yo very much!!

Oh yeah and test the living crap out of it, preferably with assert_xpath, because it's going to be a major hazard at code upgrade time!

i didnt understant the assert_xpath

thak you anyway i will check for information!!!

Felipe Vergara wrote:

i didnt understant the assert_xpath       > <%= link_to_remote render(:partial => 'my_partial'), :url     => {...} %>

When you test that, it will produce an <a>, so capture that. First put a <div id='clickable_div' around the linker. Then capture it like this:

   assert_tag_id :div, :clickable_div do      assert_xpath 'a' do |a|        assert{ a[:href] == '#' }        puts indent_xml      end    end

When you run that test, the puts indent_xml will spew out the contents of the partial inside the <a>.

Then you can call assert_tag_id or assert_xpath, again, to find some detail inside the partial.

This way, a change that looks harmless, to the <a> or the partial, has greater odds of raising a red flag instantly, while testing.

thank you very much!!