Hi folks,

I've written a small script to deal with deleting content from my
application.  When you view the admin index screen for a content type,
it's displayed as a table of content.  In the last cell there are some
actions such as view, edit and delete.  The script below works for
deleting the post from my system, but when it is sucsessful I also
want to hide the table row.

A typical row looks like this:

<tr id="post-8" class="odd">
                        <td>8</td>
                        <td>Test Post</td>
                        <td>2007-07-20 17:27:00</td>
                        <td>0</td>
                        <td><a 
href="/admin/users/view/1">WebrocketAdmin</a></td>
                        <td><a 
href="/admin/subjects/view/1">Uncatagorised</a></td>
                        <td>0</td>
                        <td>Tag 1, tag 2</td>
                        <td>Yes</td>
                        <td>Yes</td>
                        <td class="actions">
                                <a href="/admin/posts/view/8">View</a>             
               <a
href="/admin/posts/edit/8">Edit</a>                          <a id="8" 
class="delete"
href="/admin/posts/delete/8">Delete</a>                      </td>
                </tr>

So far the code I have is below:

$j('a.delete').bind('click', function(){
                var deletelink = this;
                var deleteid = $(deletelink).attr('id');
                var x=window.confirm("Are you sure you want to delete?")
                if(x) {
                        $j.post(deletelink.href, {id: deleteid}, 
function(deleteid){
                                $j('tr').attr('id', 'post-' + 
deleteid).slideUp('slow');
                        });
                        return false;
                } else {
                        return false;
                }
        });

When the code executes, it does delete the post from the system, it is
then supposed to find the corresponding row and the slideUp is fired.
But instead of just the row, the whole table disappears!

The code also seems ugly to me, does anyone have a more elegant
solution, maybe finding the parent <tr> of the link??

Thanks

--
Tane Piper
http://digitalspaghetti.tooum.net

This email is: [ ] blogable [ x ] ask first [ ] private

Reply via email to