Sun 28 Oct 2007
Many of the questions for Impromptu are concerning how exactly to use Impromptu as a confirm to remove an element from a list(database or just the dom). Its actually pretty easy, and so I whipped up an example of removing users from a database. Each user has a userid which I pass to the php file, the php file passes back true/false if it was successful. Then we remove the user from the html dom or either throw an error message. The examples can be found here, just view the source for the code:
Delete users from a list
http://www.trentrichardson.com/Impromptu/demos/demo1.html
Edit users from a list
http://www.trentrichardson.com/Impromptu/demos/demo2.html

October 29th, 2007 at 11:01 am
Trent, you rock!
I’ll take a closer look but this appears to be exactly what I was looking for.
Thanks for your help, really appreciate it.
Chris
November 1st, 2007 at 10:47 am
Trent,
Ive implemented the modal delete box and it works nice and I really like the edit example as well and I’ll be implementing that as well.
I have 1 last item I was wondering if you could help me with that I’m sure others must come across when doing web apps.
Basically I have a system that allows admin people to manage things like articles, faqs etc and they always want to be able to order them as they see fit. For example they would want to see 1 article show up above another when displayed out on a webpage. In the past I always utilized a system whereby they inputted a number (display precedence) and based on this, that is how they were outputted.
What I would like to do is simply allow them to drag and drop a and have that update the dbase accordingly. So there might be say 10 articles listed out and the user could simply and visually see the order and if necessary simply click on 1 article and drag it to wherever they wish and upon releasing it the dbase would get updated. I’m not sure if you’ve tackled this one before and I’m sure it’s a bit more complex (especially the updating of the dbase) Where I get lost is that I’m sure I need to somehow get the order of the div id’s and based on that loop through and update the dbase but just not grasping it.
Thanks for your help and I plan on providing a few impromptu design samples as well for others to use.
Chris
November 1st, 2007 at 11:34 am
Hi Chris,
It appears you are looking for something like:
http://jquery.com/plugins/project/NestedSortable
Click “Try out a demonstration” for some samples. If that’s not exactly what you’re looking for you may want to try jQuery UI as it also has a sortable plugin. or Interface:
http://interface.eyecon.ro/demos
Each time the sortables are reordered they should pass the new list of items back to you in their correct order via their callback function. Then just as you did with Impromptu you will make an ajax post to update your database. Hope that helps! I also look forward to seeing your Impromptu designs!
January 14th, 2008 at 4:59 am
Hey there. Before I show this keep in mind I’m a total newbie at Javascript. But I copied your code and modified it slightly, and am having a TON of trouble getting the edit function to do anything.
http://cosmeticalchemy.com/retailers/dashboard.php
Any help you could give on why the submission on edit is not going through would be GREATLY appreciated. Just click on the first product name.
Thank you SOOOOO much.
Bryan
January 14th, 2008 at 8:01 am
Hey Bryan,
It looks like in your editPrompt() your id for editname is wrong, one says editproduct(prompt text), the other says editname(in the submit validation). Hope that helps! Looks good!
Trent
February 22nd, 2008 at 7:09 am
something wrong here I suppose…
$.post(’removeuser.php’,{userid:uid}, callback:function(data){
February 22nd, 2008 at 7:58 am
Hey Martin,
I have that commented out since I didn’t write the php side to the script. If you’re trying to get the php side to work then be sure you’re printing out “true” or “false” from the php. Also you might want to add $.trim() to that if statement:
$.post(’removeuser.php’,{userid:uid}, callback:function(data){
if($.trim(data) == ‘true’){…
February 22nd, 2008 at 8:19 am
Hi Trent
I am getting an error exactly on that line and on the click of the “delete” nothing happens at all apart from receiving an error.
I removed callback: leaving just function(data) and it works great.
I am using jquery 1.2.3
February 22nd, 2008 at 9:21 am
It could be a difference in versions of jQuery, that example runs on 1.2.1. It’s getting about time for me to update the examples again.
February 29th, 2008 at 4:04 am
Trent, can I ask you how can I get the php file to send back data to the original script?
// if($.trim(data) == ‘true’) {
February 29th, 2008 at 8:46 am
Hey Martin,
the $.post will call the php file:
$.post(’removeuser.php’,{userid:uid}, callback:function(data){
then in the call back the “data” function parameter will have the output of the php file, so within your php file if the action is successful you can do echo “true”; or echo “false”; if the action is not successful. For this script it is only looking for a one word response. You could however create xml, but then you will need to parse it on the jquery side. I was shooting for the simplest possible example.