> I do not really want to use an inline onclick, but I am a javascript
> newbie, and I was unsure how to still pass the two variable to the
> function if I did not do it inline.  How could I rewrite this so that
> my function will still work, but "re-factoring" as you say?

You never showed us where "action" comes from or why "assetid" is
needed, but here's a quick refactoring:

$('a').click(deleteAjaxAsset);

function deleteAjaxAsset() {
    var url = $(this).attr("href");
    if (action == "delete" &&
        confirm('Are yous ure you want to delete?')) {
        $.ajax({
            type: "POST",
            url:  url + "?action=delete"
        });
    }
    return false;
};

You could also get rid of the named function deleteAjaxAsset
altogether and use an anon fn instead.  But that's just a matter of
style.

Mike

Reply via email to