er:
  var asseturl = $("#"+assetid).attr("href");

On Jul 18, 12:14 pm, EllisGL <[EMAIL PROTECTED]> wrote:
> Try this:
> function deleteAjaxAsset(message, assetid)
>  {
>   var asseturl = $("#"+assetid.attr("href"));
>
>   alert(asseturl);
>
>   var confirmDelete = confirm(message);
>
>   if(confirmDelete == true)
>    {
>     if(action == "delete")
>      {
>       $.ajax(
>        {
>         type : "POST", url : asseturl + "?action=delete" }
>        );
>       }
>     }
>   }
>
> $(this) refers to itself - since you had $(this) inside a function -
> it's referring the the function itself.
>
> if you had something that was somewhat like this
> <a href="#" id="myid" onclic="myfunction($(this);)">Click</a>
>
> It would send the properties of the "a" tag in which it's contained to
> the argument of the function.
>
> <a href="http://www.testpage.com"; onclick="deleteAjaxAsset('Are you
> sure you want to delete?','testid'); return false;">Delete</a>
> On Jul 18, 11:58 am, hubbs <[EMAIL PROTECTED]> wrote:
>
> > I might be getting confused about the proper use of "this".  I thought
> > I understood how this worked, and that since I am triggering the
> > onclick even on an anchor, that the "this" would be in the context of
> > that anchor tag, so that I could grab its href.
>
> > Here is what I have done, but it is returning undefined for asseturl.
>
> > function deleteAjaxAsset(message, assetid) {
> >    var asseturl = $(this).attr("href");
> >    alert(asseturl);
> >    var confirmDelete = confirm(message);
> >    if (confirmDelete == true) {
> >       if(action == "delete") {
> >          $.ajax( {
> >             type : "POST", url : asseturl + "?action=delete" }
> >          );
> >          }
> >       }
> >    }
>
> > <a href="http://www.testpage.com"; onclick="deleteAjaxAsset('Are you
> > sure you want to delete?','testid'); return false;">Delete</a>
>
> > Thanks guys!

Reply via email to