Hi all,
We''re developing a Rails application and we''ve done some
multiple updates
using Ajax. It works fine, but I wish to know if the "pattern" we used
is
right or there''s a better way (a rails way indeed). My english is a
little
poor, but I''ll do my best.
Say you have a list of some kind of object and a form below that list to
add/update new objects (if you click on "add" link the former is
shown; if
you click on an element from the list, the "update" form is shown).
<div id="list">
render :partial => ''list''
</div>
<div id="form">
render :partial => ''update''
</div>
When you try to submit new elements:
1) if it''s ok, an "update.rhtml" is rendered which reload the
list (that''s the
question).
2) if something goes wrong, only updates the form to reflect the error.
Nothing else have to change.
To reload the list you could use some javascript to insert/update/remove
elements. No problem. But if you wanna keep the list ordered, it''s
became a
little tricky (I don''t wanna put the ''order logic''
into javascript code).
So, you could render the list again when the "add/update" is done but,
here''s
my question, you''ll have to set up a list of elements (say in
@elements) at
the end of that action (add or update). So, is right to worry about setting
this kind of things at the end of actions that really have nothing to do with
''show the list of elements'' (like ''add'' or
''update'')?
Maybe I''ll try to get the list doing a kind of "show_lists"
request and
rendering the response (but it''s another new request against the
server).
I figure that''s not a problem, but I''d like to read
suggestions from you.
Thank you if you have read ''till the end ;)
--
_o) Imobach González Sosa
//\ email: imobachgs at banot dot net
V_/_ jid: osoh at jabberes dot org
url: http://www.banot.net/~osoh/
blog: http://devnull.blogs.banot.net
--
Este mensaje ha sido analizado por STEP On Line
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio. 902 10 18 43