It is not a good pratice to use render :update like that. When the RJS
is more than a one-liner, say, it is more clean to extract that to its
own RJS template. Because RJS belongs to the V in MVC.
On the other hand the idea of the loop + calls to page...something is
correct. In your example the ID of the element is always the same
though. Knowing this, you could for example simplify the code like
eliminating the conditional to get a wrong but working version, and
after that add all the logic.
I am presumably missing something here, as I do not know much about
RJS, but inside the loop you seem to be replacing the html for the
same div ("test_div") every time round the loop.
"Checked Out"
else
page["test_div"].replace_html
"Available"
end
end
end
end
Executing this code only updates a single element.
I am presumably missing something here, as I do not know much about
RJS, but inside the loop you seem to be replacing the html for the
same div ("test_div") every time round the loop.
Colin
Oh. :facepalm:
Does anyone know how to dynamically generate div tags?
I tried this:
<th><div id = "test_div_" + ij"" style = "display :inline;"> Available
</div></th>
Which didn't work, rather it gives me this in the source:
<th><div id = "test_div_" + ij"" style = "display :inline;">
Available </div></th>
The idea being that I would be able to use my loop to generate the div
tags.