views:

31

answers:

1

I have a page which has a list item, and each item has a delete button. Clicking the delete button loads the child page (delete.asp?id=123) in a hidden div.

delete.asp has a javascript alert (on document ready) which successfully fires when the button is clicked. It also has $("a:focus").hide(); which removes clicked link. I can't seem to get this to work in Chrome. The alert fires but the link doesn't remove itself.

Besides using a:focus, is there a better way to do this?

A: 

Rather than removing the link from the loaded page, you should probably be removing it in the same event that loads the hidden page. Something like this:

$('a.delete').click(function() {
    //load delete.asp
    $('#myHiddenDiv').load('delete.asp?id=123');

    //hide the link
    $(this).hide();
});
Ender
I'm actually trying to avoid coding a listener for each function. In addition to delete, I'll have an edit link, and so on. They all have a rel of "ajax".
koleslaw
Don't you already have to have a listener in order to load the external page?
Ender
On the parent page, I have a listener for only a[rel='ajax']. Nothing more specific than that. I'd like to keep my parent page clean, and handle all the errors on the function's page.Anyway, I have found an alternate solution that works. What I do in the delete.asp file is to figure out what ID is in the querystring, and then target the the anchor tag that matches, $(a[href='delete.asp?id=<%=request.querystring("id")%>']).hide();
koleslaw