I'm really becoming a broken record, eh? Or, for you kids in the audience, a degraded MP3 file. By
request,
I put together a full demonstration of how documents can be created,
edited, and deleted using AJAX, all without the use of any agents. You
can try it out here. And you can download the demo database here.
Previously, I described how documents can be created and edited
in a Domino database without calling agents. This demo combines the two
- as well as deletion of documents - using a simple contact manager as
an example. The UI is very primitive, but hopefully it illustrates the
premise.
In this example, contact information can be entered and then posted to
the server without a page refresh. The function that posts the document
(thereby creating a new record in the database) in turn calls the
function that loads the view data (thereby displaying the newly created
record). The new data could of course be inserted into the table
immediately instead of reloading the view, but this approach was
intended to illustrate how much faster document creation is when agents
aren't involved. Reloading the view also ensures that the new record
will already be sorted correctly when it's added to the table. In
addition to document creation, each view row includes a link to allow
editing and deletion of existing documents.
Please feel free to post any questions or suggestions you may have
about this... I was planning to write up a far more detailed
explanation of how all of this is tied together, but I'm suddenly very
sleepy.
Oh, one thing I should mention: the reference to Event.onDOMReady at
the end of ajaxeditor.js isn't part of the core prototype.js. It's an
extension I found on Vivabit.
This allows functions to be defined in external js files that would
otherwise need to be called inline or via window.onload... for example,
functions that you want to run immediately, but not until some DOM
element that the function is going to muck with is actually ready to
receive said mucking. The primary advantage of this extension is that
it triggers the functions as soon as it is safe to do so, instead of
waiting for the entire page to load (images, for example).
(cross-posted from TimTripcony.com)