[jQuery] Re: passing more than 1 param via click()?

2009-04-19 Thread kgosser

Bump. I'm really looking for a solid tip here :). Thanks everyone.

On Apr 17, 9:48 am, kgosser  wrote:
> Here's a better example with HTML. See, I said it was hard to explain
> in the first place :).
>
> Ok, so basically think of this as a list of things where the HTML is
> always going to be the same, but there could be between 1 and N rows.
> I'm trying to remove the onClick, and target just the link's class so
> that when a specific link is licked, that specific row is removed.
>
> Here's some example HTML iterated:
>
> 
>         Example A
>         Remove
> 
> 
>         Example B
>         Remove
> 
>
> I want to take out the onClick. So here's what I got in the
> JavaScript:
>
> $(document).ready(function(){
>         // consider the example "123" as the dynamic ROW_ID
>         // consider the example "listA" as the dynamic  LIST_ID
>         $(".remove-link").click(function(){
>                 exampleAjaxFunction(ROW_ID,LIST_ID,function(){
>                         // call back if deleted from DB
>                         $(this).parent().remove();
>                 });
>                 return false;
>         });
>
> });
>
> And so my question is. I don't know how to pass ROW_ID and LIST_ID
> to the single function like the onClick could.. Normally with just one
> param to pass, I could grab it by targeting an 's rel attribute.
> But now there are TWO, and that's my point...There has to be a better
> way to get those than just getting attributes, and that's what I'm
> trying to figure out.
>
> Thanks for the help again everyone.
>
> On Apr 17, 12:15 am, "Michael Geary"  wrote:
>
> > I must be missing something obvious, but it sounds like you're not just
> > working with some predetermined HTML, but you have the flexibility to tweak
> > that HTML code, is that right?
>
> > Then why can't you generate this as part of your HTML page:
>
> >     
> >         // initialize some variables here
> >     
>
> > That *is* HTML code, isn't it?
>
> > -Mike
>
> > > From: kgosser
>
> > > I have two values that are only found in a loop in the HTML.
> > > They need to be passed to the single function in the document.ready().
>
> > > I can't set them in the JavaScript. I have to "find" them
> > > somehow in the HTML. Whether I find them as hidden inputs or
> > > something, or as tags to the anchor, or as params passed in
> > > somehow. I'm not sure what's best.


[jQuery] Re: passing more than 1 param via click()?

2009-04-17 Thread kgosser

Here's a better example with HTML. See, I said it was hard to explain
in the first place :).

Ok, so basically think of this as a list of things where the HTML is
always going to be the same, but there could be between 1 and N rows.
I'm trying to remove the onClick, and target just the link's class so
that when a specific link is licked, that specific row is removed.

Here's some example HTML iterated:


Example A
Remove


Example B
Remove


I want to take out the onClick. So here's what I got in the
JavaScript:

$(document).ready(function(){
// consider the example "123" as the dynamic ROW_ID
// consider the example "listA" as the dynamic  LIST_ID
$(".remove-link").click(function(){
exampleAjaxFunction(ROW_ID,LIST_ID,function(){
// call back if deleted from DB
$(this).parent().remove();
});
return false;
});
});

And so my question is. I don't know how to pass ROW_ID and LIST_ID
to the single function like the onClick could.. Normally with just one
param to pass, I could grab it by targeting an 's rel attribute.
But now there are TWO, and that's my point...There has to be a better
way to get those than just getting attributes, and that's what I'm
trying to figure out.

Thanks for the help again everyone.

On Apr 17, 12:15 am, "Michael Geary"  wrote:
> I must be missing something obvious, but it sounds like you're not just
> working with some predetermined HTML, but you have the flexibility to tweak
> that HTML code, is that right?
>
> Then why can't you generate this as part of your HTML page:
>
>     
>         // initialize some variables here
>     
>
> That *is* HTML code, isn't it?
>
> -Mike
>
> > From: kgosser
>
> > I have two values that are only found in a loop in the HTML.
> > They need to be passed to the single function in the document.ready().
>
> > I can't set them in the JavaScript. I have to "find" them
> > somehow in the HTML. Whether I find them as hidden inputs or
> > something, or as tags to the anchor, or as params passed in
> > somehow. I'm not sure what's best.


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Michael Geary

I must be missing something obvious, but it sounds like you're not just
working with some predetermined HTML, but you have the flexibility to tweak
that HTML code, is that right?

Then why can't you generate this as part of your HTML page:


// initialize some variables here


That *is* HTML code, isn't it?

-Mike

> From: kgosser
> 
> I have two values that are only found in a loop in the HTML. 
> They need to be passed to the single function in the document.ready().
> 
> I can't set them in the JavaScript. I have to "find" them 
> somehow in the HTML. Whether I find them as hidden inputs or 
> something, or as tags to the anchor, or as params passed in 
> somehow. I'm not sure what's best.



[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Joseph Le Brech

you can also make custom attributes, they don't have to be called "rel" so you 
can have as many attributes as you want.

> Date: Thu, 16 Apr 2009 15:15:44 -0700
> Subject: [jQuery] Re: passing more than 1 param via click()?
> From: kgos...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> That's a good point, Josh. I thought of that earlier, but I wanted to
> make sure this was the best way. For only passing two params, that's
> not that bad of an idea, but I was checking to see if there was a best
> practice here, like hopefully passing the params through somehow.
> 
> On Apr 16, 5:04 pm, "Josh Nathanson"  wrote:
> > You could do something like:
> >
> >  // 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:
> >
> >  >  href="#drop"
> >  class="edit-link"
> >  onclick="
> >   removeDept('','');
> >   return false;"
> > >Remove Department
> >
> > 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.

_
Share your photos with Windows Live Photos – Free.
http://clk.atdmt.com/UKM/go/134665338/direct/01/

[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread kgosser

That's a good point, Josh. I thought of that earlier, but I wanted to
make sure this was the best way. For only passing two params, that's
not that bad of an idea, but I was checking to see if there was a best
practice here, like hopefully passing the params through somehow.

On Apr 16, 5:04 pm, "Josh Nathanson"  wrote:
> You could do something like:
>
>  // 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:
>
>       href="#drop"
>      class="edit-link"
>      onclick="
>           removeDept('','');
>           return false;"
> >Remove Department
>
> 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.


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread kgosser

I think you've misunderstood my question.

I have two values that are only found in a loop in the HTML. They need
to be passed to the single function in the document.ready().

I can't set them in the JavaScript. I have to "find" them somehow in
the HTML. Whether I find them as hidden inputs or something, or as
tags to the anchor, or as params passed in somehow. I'm not sure
what's best.

Basically, there could be 10 "edit-link" classes, but when a specific
"edit-link" anchor is clicked, I need to perform an Ajax function that
needs two params passed into it that are unique to that "edit-link".

On Apr 16, 4:53 pm, Joseph Le Brech  wrote:
> i think itll be covered in this.
>
> http://stackoverflow.com/questions/224820/how-do-you-pass-arguments-t...
>
>
>
> > Date: Thu, 16 Apr 2009 14:46:41 -0700
> > Subject: [jQuery] passing more than 1 param via click()?
> > From: kgos...@gmail.com
> > To: jquery-en@googlegroups.com
>
> > 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:
>
> >  >      href="#drop"
> >      class="edit-link"
> >      onclick="
> >           removeDept('','');
> >           return false;"
> > >Remove Department
>
> > 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.
>
> _
> View your Twitter and Flickr updates from one place – Learn 
> more!http://clk.atdmt.com/UKM/go/137984870/direct/01/


[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Josh Nathanson

You could do something like:

 // 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:

','');
  return false;"
>Remove Department

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.



[jQuery] Re: passing more than 1 param via click()?

2009-04-16 Thread Joseph Le Brech

i think itll be covered in this.

http://stackoverflow.com/questions/224820/how-do-you-pass-arguments-to-anonymous-functions-in-javascript

> Date: Thu, 16 Apr 2009 14:46:41 -0700
> Subject: [jQuery] passing more than 1 param via click()?
> From: kgos...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> 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:
> 
>   href="#drop"
>  class="edit-link"
>  onclick="
>   removeDept('','');
>   return false;"
> >Remove Department
> 
> 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.

_
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/