You could do something like:

<a rel="val1_val2"> // use a delimiter that makes sense for your values

Then split the rel:

var arr = this.rel.split('_'), val1 = arr[0], val2 = arr[1];

removeDept( val1, val2 );

-- Josh

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of kgosser
Sent: Thursday, April 16, 2009 2:47 PM
To: jQuery (English)
Subject: [jQuery] passing more than 1 param via click()?


Hey all,

Not really sure how to ask this, so I'm sorry if my title is mis-
leading. It is also why I wasn't able to find much searching, so I'm
sorry if it's answered already.

Basically, the code I inherited was this:

<a
     href="#drop"
     class="edit-link"
     onclick="
          removeDept('<c:out value="${key}" />','<c:out value="$
{name}" />');
          return false;"
>Remove Department</a>

And that is in an iteration, so the two values passed to the
"removeDept" function are always dynamic.

I'm trying to handle this in the document.ready(). Normally, I throw
the would-be dynamic param passed as a rel tag on an anchor, and
that's how I retrieve things when I clean up code like this.

However, I'm scratching my head for the *best* way to handle this with
the two params now... How do you guys recommend I handle something
like that?

$(document).ready(function() {
        $(".edit-link").click(function(){
               removeDept($(this).attr("rel"),$(this).attr("rel"));
               return false;
        });
});



Obviously I can't have two rel attributes :)


Thanks in advance.

Reply via email to