TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   What would you do? (http://www.talkphp.com/absolute-beginners/2385-what-would-you-do.html)

Gareth 03-01-2008 05:37 PM

What would you do?
 
Hey guys

Sorry to trouble you again but I would like your advice.

In my members control panel, I have the option to view the different codes of the images which they have uploaded, and to delete them.

I know I can literally go

Code:

<form method="bla" action="bla">
<input type="submit" name="delete_$id" value="delete image">
</form>

for each image, but surely that would be terribly a lot of code for such a simple thing?

But there's an extra layer on top of this: that is I want AJAX to load / do the deleting without the page reloading. Other wise I could have done it by a link with the id=$id, but would that work with AJAX?

Am I explaining myself well? :P

What would you do?

Gareth

Wildhoney 03-01-2008 07:58 PM

Personally, I would say that's one of the prime areas to use AJAX. After all, once you delete a single item via a text link, the page will reload and return to the very top of the page, making you scroll back down to where you deleted the item from (if you can remember). At the very least people should be using check-boxes to delete many at a time.

Use Prototype to do the AJAX call and actual deletion of the row upon success. You would be able to do it in 10 minutes, with 10 lines of code -- max!

Gareth 03-02-2008 10:16 AM

So should I use a form / input button for each image rather than using a link (<a>)?
Thanks WH :)

flyingbuddha 03-02-2008 06:36 PM

Personally, I don't like the delete one-at-a-time thing. When I build cms's I put a little checkbox next to the record so that multiple items can be selected and deleted at once, it also gives the opportunity to present an 'are you sure you want to delete these records' sort of prompt.


All times are GMT. The time now is 10:22 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0