RJS: Check for existing page element?

I've come up on this many times where I have a conditional item that needs to be acted upon if it exists. Using page. Select avoids the Null Value error.

I've come up on this many times where I have a conditional item that needs to be acted upon if it exists. Using page. Select avoids the Null Value error.Page.

Select('#dom_object_id'). Each do |element| element. Value = "bar" end I put this in my *.js.

Rjs file. When the select sends an empty array to each it returns nothing instead of the TypeError you'd get when directly selecting by id when no DOM object with the correct ID is on the page.

Thanks a lot for the RJS solution! – Javier Mar 11 '09 at 9:35.

I don't think you can from RJS. As a workaround, you can simply call a javascript method from RJS that checks if the element exists. Page = undefined ) { $('foo').

Value = 'bar'; } } Edit Fixed the ruby part..

Works like a charm (besides that there's no need to use "! = undefined"). As long as there's no solution in RJS this would be my solution.

– Javier Mar 10 '09 at 15:46.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions