[q]
Originally posted by: Brad Balfour
I've got a simple spry dataset displayed on my page. I am looking to allow the
user to do a simple edit in place of a value. I use the Spry.Effect.Fade and
Spry.Utils.addClassName to hide the content and show the editable field. Once
the value has been changed in a text field, then either to save the change or
to cancel.
My cancel function is almost working correctly. I do a combination of
Spry.Effect.Fade and Spry.Utils.addClassName/Spry.Utils.removeClass name to
show/hide the original data. However, this left the original field still with
an opacity of 0. Even doing a Spry.$(tagDiv).style.opacity = 1 wouldn't force
it to be visible.
I worked around this problem by adding a dsTags.loadData(); call to the bottom
of my cancel function. On the plus side this does restore the dataset back to
its initial condition. However, this now has the side-effect of scrolling the
display back to the top of the entire page. So, if I have 100 rows and the
users cancels an edit on the 99th row, the will no longer be positioned at that
same location. :-(
Does anyone know how I should be doing this to correctly restore the cancel
the edit and yet leave the page in the same vertical location?
Secondly, I anticipate the same problem with the "Change" button. I'll submit
the edit to the server, but the dsTags.loadData() will cause the page to scroll
to the top. Do I need to manually alter the content of the spry dataset row via
some JavaScript calls after submitting the change to the server asynchronously?
Thanks,
Brad
[/q]
Hello Brad,
About your first issue, Did you check if the element had display:none? And if
is possible, can you provide a online url for it? Because having to do a new
LoadData() isnt the most elegant solution of fixing this issue.
You can "by pass" the scrolling by just storing the current scroll location in
a global variable and use a onPostLoad observer to reset the last used scroll
position. (I also use this technique

)
And maby i got a better solution for you,
I'm currently at Adobe Max 2008 Milano, and in the time that I had to wait
between sessions I have been working on a inline editing functionality.
If you wish I could share it with you. I will be writing a huge indepth
article about it. As I see this get requested allot. And I just wanted to show,
how easy it actually is to build it.
You can contact me by sending a email to
hello@3rd-Eden.com