Mark from NZ had an interesting question about Spry:
I have a question regarding Spry, I have a simple dataset, one of the columns is a simple publish button, if on it displays a green image if off red etc. I was wondering if I can create an ajax call whenever the image is clicked it updates the database and dataset to show my changes. At the moment, when it is clicked it browses away from the page performs the update then a cflocation to take you back to show the changes which is a bit cumbersome.
Absolutely! First off - Spry can do calls back to the server for any number of purposes. Sending data back as a FORM post is relatively simple. First start off by reading:
This will cover how you can send you data updates back to the server. How do you then refresh the current dataset? The Spry Dataset object has a loadData() method that - well - loads the data. One typical use case is to tweak the URL and reload the data:
dsData.url = "/index.cfm?event=xml.starbuckisntdead";
dsData.loadData();
loadData() by itself should be all you need, but if you run into IE caching issues than you could do the old random number in the URL trick.
Archived Comments
So what do you think happened to Starbucks? Inquiring minds want to know . . .
Thanks Ray, I have managed to get the links working as you described above and in the referenced post. I am getting a problem with caching over the red and green images but am sure I will work through that. In the final bit of code where you reload all the data
dsData.url = "/index.cfm?event=xml.starbuckisntdead";
dsData.loadData();
would you just add a javascript random number to the end of the url.
Also is it possible to update just the row with the new information rather than relaoding all the data, or am I getting a we bit ambitious. Anyway really happy to be moving long with spry and should find plenty of uses for it.