[jQuery] Re: click action effect/problem

2010-01-20 Thread Scott Sauyet
> I'd like to thank you guys again for the quick response, but for some
> reason, both methods aren't working.

I made two suggestions.  MorningZ's suggestion was very much like my
first one.  My second one is a bit more general, and might help.

I modified MorningZ's page here:

http://jsbin.com/ejuga3/3 (code: http://jsbin.com/ejuga3/3/edit)

Can you try my second one to see if that works?

  -- Scott


[jQuery] Re: click action effect/problem

2010-01-18 Thread Legostrat
I'd like to thank you guys again for the quick response, but for some
reason, both methods aren't working.  With the first method, when you
click on the containing div, in this case #twitter,  it reveals the
div with the content, #flwtwitter.  However, when you click on it a
second time it tries to minimize, but does it horizontally, and then
stops.  It never really hides again.  It jumps a bit also.  Maybe
this'll help:

$("#twitter").click(function(e) {
var $tgt = $(d.target);
if ($tgt.is("#flwtwitter")) {
return false;
}
if($(this).find("#flwtwitter").is(':hidden')
{
$(this).animate(
{
width: "248px"
}, 100, function()
{

$(this).find("#flwtwitter").fadeIn("fast");
}
);
}
else if ($(this).find("#flwtwitter").is(':visible'))
{
$(this).find("#flwtwitter").fadeOut("fast", 
function()
{
$(this).animate(
{
width: "120px"
}, 300)
}
);
}
});

I also tried the second method, and when clicking on the containing
div, nothing happens.

This is the same section of the jquery code with the second method:

$("#twitter").click(function(event) {
if (event.target.id != "#flwtwitter") return;
if ($("#flwtwitter").is(':hidden'))//if quick menu isn't visible
{
$("#twitter").animate( //show menu on click
{
width: "248px"
}, 100, function()
{
$("#flwtwitter").fadeIn("fast");
}
);
}
else if ($("#flwtwitter").is(':visible'))  //if quick menu is
visible
{
$("#flwtwitter").fadeOut("fast", function()
{
$("#twitter").animate(
{
width: "120px"
}, 300)
}
); //hide menu on click
}
});




[jQuery] Re: click action effect/problem

2010-01-18 Thread Legostrat
Thanks guys!


[jQuery] Re: click action effect/problem

2010-01-18 Thread Scott Sauyet
On Jan 18, 4:07 pm, Legostrat  wrote:
> 
>    Click here
>       
>        option 1
>        option 2
>       
> 
>
> So, when you click on the button div, it reveals the sub-menu div.
> The problem is that when you click on the content within the sub-menu
> it activates the .click action attached to the button div.

I didn't go to the live site, but if your markup is as simple as that
(i.e. "Click here" is directly in the outer div) then this might be
all you need:

$("#button").click(function(event) {
if (event.target.id != "button") return;
$("#submenu").toggle();
});

If the click here is nested deeper, you might need something more like
this:

$("#button").click(function(event) {
if ($(event.target).closest("#submenu").length) return;
$("#submenu").toggle();
});

The idea is simply to ignore those events that are inside the submenu.

Cheers,

  -- Scott


[jQuery] Re: click action effect/problem

2010-01-18 Thread MorningZ
Hope this helps put you on the path

http://jsbin.com/ejuga3 (run)
http://jsbin.com/ejuga3/edit (edit)

Event Delegation = awesome knowledge to have

http://www.learningjquery.com/2008/03/working-with-events-part-1

On Jan 18, 4:07 pm, Legostrat  wrote:
> Hey,
>
> I've got a toolbar on the bottom of my website, and I've got it to
> where a user clicks on a div tag, and it reveals another div tag,
> which contains the content described in the previous div.  So if a
> person clicks on the div with share in it, a hidden div is revealed
> containing links to various social bookmarking options.
>
> Now, the button div contains the div that has the content.  It's sorta
> like this:
>
> 
>    Click here
>       
>        option 1
>        option 2
>       
> 
>
> So, when you click on the button div, it reveals the sub-menu div.
> The problem is that when you click on the content within the sub-menu
> it activates the .click action attached to the button div.
>
> I'm fairly sure this is normal behavior, but I'm not sure how to
> prevent it.  I'd to be able to click on the content within the sub-
> menu and not have it activate the .click action attached to the button
> div.
>
> The reason I put the sub-menu within the button div, is that the
> button div animates to a wider width, and if I didn't put it inside,
> it the sub-menu would stay in place and not shift with the button div.
>
> Sorry about all the wordiness.
>
> Any solutions would be greatly appreciated.
>
> My website: calxanime.com
>
> The jquery is contained 
> at:http://calxanime.com/smf/Themes/mobile_alt/scripts/jquery.custom.js
>
> Sign in to see the bottom bar with the username: Guestperson
> and the password: guest
>
> Thanks,
> Legostrat


[jQuery] Re: click event is not working

2010-01-08 Thread CreativeMind
thanx a lot!

On Jan 8, 3:07 am, Charlie Griefer  wrote:
> http://docs.jquery.com/Events/live
>
>
>
> On Thu, Jan 7, 2010 at 2:01 PM, CreativeMind  wrote:
> > hi,
> > i'm appending a child div in a parent div. parent div has already
> > child div's which have classes ws_c1 and plus.
>
> > $('').addClass('ws_c1').addClass('plus').appendTo($
> > ('#'+'parentdiv'+counter));
>
> > but when i try to do this
> >  $(".ws_c1.plus").click(function() {alert('test');});
> > It works on other child div's but not on the appended div's. I've also
> > tried with Id's.
> > can you plz help me.
>
> > regards,
>
> --
> Charlie Grieferhttp://charlie.griefer.com/
>
> I have failed as much as I have succeeded. But I love my life. I love my
> wife. And I wish you my kind of success.


[jQuery] Re: click(function{ problem with Firefox

2009-12-24 Thread turnavies
ah look at that, img is an inline element :D
standards ftw!

On 24 dec, 23:10, turnavies  wrote:
> Thanks for your replies!
> FF is happy now, although it's not fully standards-compliant (I still
> have an img inside my label), but the code is a lot cleaner and it
> works on the major browsers (haven't tested IE though :D)
>
> Nice diagram!
>
> Thomas


[jQuery] Re: click(function{ problem with Firefox

2009-12-24 Thread turnavies
Thanks for your replies!
FF is happy now, although it's not fully standards-compliant (I still
have an img inside my label), but the code is a lot cleaner and it
works on the major browsers (haven't tested IE though :D)

Nice diagram!

Thomas


[jQuery] Re: click(function{ problem with Firefox

2009-12-24 Thread Šime Vidas

Yea, that happens if you don't follow the standard some browser
will break your code :)

For a comprehensive overview of propper HTML nesting rules, consult my
diagram:
http://vidasp.net/HTMLstructure.htm


[jQuery] Re: Click event outside of an element

2009-12-03 Thread Keysher
Umm, It seems fine, I'll check it later.

Thanks!

On 23 nov, 15:13, Dustan  wrote:
> Perhaps something along these lines is what you are looking for?
>
> $(document).click(function(event) {
>     if (!$(event.target).hasClass('classname')) {
>         // run this code if anywhere in the document except the item
> is clicked
>     }
>
> });
>
> On Nov 20, 8:29 am,Keysher wrote:
>
>
>
> > Hi!
>
> > I am newbie in JQuery. I want to catch click event outside and
> > specified class.
>
> > For example, I have a div with class "classname", and I want to attach
> > some actions when I click outside, in the rest of the page.
>
> > I tried with this (to get the classname where I click):
>
> > $('*').click(function(){
> >         alert($(this).attr('class'));
>
> > });
>
> > But not works!
>
> > Any idea?
>
> > Thanks!
>
> > P.D: sorry for the bad english!- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -


[jQuery] Re: Click Even

2009-12-03 Thread shapper
On Dec 3, 2:52 am, JMcGinnis  wrote:
> y0, Not really, why do you need to/ or want to? you could do this
>
> $('#Play').click(function() { $.cookies.set('WCA.Player', 'Play', { path:
> '/' }) })
>
> ha, j/k same thing, just one line.  Could you just explain why you would
> like to do it a different way? or where you just wondering?

I was just wondering ... Thank you.


[jQuery] Re: Click event outside of an element

2009-11-23 Thread Dustan
Perhaps something along these lines is what you are looking for?

$(document).click(function(event) {
if (!$(event.target).hasClass('classname')) {
// run this code if anywhere in the document except the item
is clicked
}
});

On Nov 20, 8:29 am, Keysher  wrote:
> Hi!
>
> I am newbie in JQuery. I want to catch click event outside and
> specified class.
>
> For example, I have a div with class "classname", and I want to attach
> some actions when I click outside, in the rest of the page.
>
> I tried with this (to get the classname where I click):
>
> $('*').click(function(){
>         alert($(this).attr('class'));
>
> });
>
> But not works!
>
> Any idea?
>
> Thanks!
>
> P.D: sorry for the bad english!


[jQuery] Re: Click event outside of an element

2009-11-22 Thread Keysher
Works fine!

Thanks!! :o)

On 21 nov, 15:29, mofle  wrote:
> Here you go:
>
> $(document).click(function(){
>         alert('clicked outside classname');
>
> });
>
> $('.classname').click(function(e){
>         e.stopPropagation();
>
> });
>
> First you bind a click event to the document with the action you want.
> Then you bind the classname to stop it from propagate up to the
> document root.
>
> On Nov 20, 2:29 pm, Keysher  wrote:
>
>
>
> > Hi!
>
> > I am newbie in JQuery. I want to catch click event outside and
> > specified class.
>
> > For example, I have a div with class "classname", and I want to attach
> > some actions when I click outside, in the rest of the page.
>
> > I tried with this (to get the classname where I click):
>
> > $('*').click(function(){
> >         alert($(this).attr('class'));
>
> > });
>
> > But not works!
>
> > Any idea?
>
> > Thanks!
>
> > P.D: sorry for the bad english!- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -


[jQuery] Re: Click event outside of an element

2009-11-21 Thread mofle
Here you go:

$(document).click(function(){
alert('clicked outside classname');
});

$('.classname').click(function(e){
e.stopPropagation();
});


First you bind a click event to the document with the action you want.
Then you bind the classname to stop it from propagate up to the
document root.





On Nov 20, 2:29 pm, Keysher  wrote:
> Hi!
>
> I am newbie in JQuery. I want to catch click event outside and
> specified class.
>
> For example, I have a div with class "classname", and I want to attach
> some actions when I click outside, in the rest of the page.
>
> I tried with this (to get the classname where I click):
>
> $('*').click(function(){
>         alert($(this).attr('class'));
>
> });
>
> But not works!
>
> Any idea?
>
> Thanks!
>
> P.D: sorry for the bad english!


[jQuery] Re: Click not running on IE

2009-10-30 Thread James
What value is in "r"? Does it have something like a # or . that makes
it a valid selector?

For example, in your code below:

var blocco = r + " div.pul";
$(blocco).each(function (i)

blocco may become 'testdiv.pul'
$(blocco), will become $('testdiv.pul'), which does nothing because
there's no element named 'testdiv'.
What you're trying to achieve maybe $('#testdiv.pul') or $
('.testdiv.pul').

On Oct 30, 9:51 am, ammaccabanane  wrote:
> Hi all.
> I'm searching for a solution to this problem: i've put a div (passed to the
> function with "r") with inside three div with class "pul". These has the
> function:
>
> function clic(r){
> var blocco = r + " div.pul";
> $(blocco).each(function (i)
> {
> $("#bloccofoto1").hide();
> $("#bloccofoto2").hide();
> $("#bloccofoto3").hide();
> $(document.getElementById("elencofoto")).hide();
> $(this).click(
> function() {
> $(document.getElementById("mostrafoto")).css("height","22.65em");
> $(document.getElementById("elencofoto")).fadeIn("slow");
> $(document.getElementById("elencofoto")).css("height","6.7em");
> if (i==0) { $("#bloccofoto1").show("slow"); $("#bloccofoto2").hide();
> $("#bloccofoto3").hide(); }
> else if (i==1) { $("#bloccofoto2").show("slow"); $("#bloccofoto1").hide();
> $("#bloccofoto3").hide(); }
> else { $("#bloccofoto3").show("slow"); $("#bloccofoto1").hide();
> $("#bloccofoto2").hide(); };
>
> }
> );
> });
> }
>
> So that they make visible a div("elencofoto") that contains three hide span
> (that contain img) by the number that comes from the "i" of the "each".
> These spans have their own spans. For example "exnovo":
>
> function clicimgex(e){
> var gruppoimmagini = e + " img.novo";
> $(gruppoimmagini).each(function (i)
> {
> $(this).click(
> function() {
> alert('Are you sure you want to give us the deed to your house?'); <
> inserited as a test
> document.getElementById("cambiaimmagine").src="exnovo/"+i+".jpg";
>
> }
> );
> });
> }
>
> This one should take the img that has been clicked (with the "each()") and
> by the "i" in each() changes the "src" attribute of the image (with name
> 0.jpg, 1.jpg, 2.jpg eccetera.. that finds in the folder) that i put in
> another div ("cambiaimmagine", that is inside "mostrafoto_img", that is
> inside "mostrafoto").
> Why?
> This image is bigger than the previous, so that you can see it bigger.
> This all runs in Firefox and Safari, not on IE 6 and 7.
> I tried to put the alert out of the "click()" and it runs, but inside not.
> What can i do?
>
> PS: i tried to use livequery, but i found it hard to implement, so if it's a
> good idea can you help me?
>
> Thanks all
> --
> View this message in 
> context:http://old.nabble.com/Click-not-running-on-IE-tp26136003s27240p261360...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread The Danny Bos


Thanks man,
I'll give it a whirl ... Thanks for all your time and energy.

d



On Oct 23, 4:19 am, mkmanning  wrote:
> Something like this (untested):
>
> var arrValues = ['c1','c2','c3','c3'],
> cnameIndex = $.inArray(this.className,arrValues)+1;
> this.className = cnameIndex===arrValues.length?0: cnameIndex ];
>
> if you can live with only one classname, otherwise you'll have to add
> code to remove the old classname from arrValues and then add the new
> class with addClass.
>
> Basically all this is doing is getting the current value of a given
> property, such as background-color, finding its index in the arrValues
> array, incrementing that by one and then setting the new value to the
> element in the array with the incremented index. If the index is at
> the end of the array, it resets to 0.
>
> On Oct 22, 4:39 am, The Danny Bos  wrote:
>
>
>
> > Thanks so much man,
> > That'll work well ... One more thing, how would I change it to point
> > to classes instead of direct colours?
>
> > var arrValues = ['c1','c2','c3','c3'],
>
> > Thanks again,
>
> > On Oct 22, 6:27 pm, mkmanning  wrote:
>
> > > Yeah, the snippet I wrote updates the color; you can add an ajax call
> > > to update your db as well, if the value your updating in the db is the
> > > color, or else the value is in an array that's indexed the same.
>
> > > On Oct 22, 12:10 am, The Danny Bos  wrote:
>
> > > > For each click of the DIV I'm hoping to change the BackgroundColor,
> > > > make some updates in the Database (depending on which array selection
> > > > it's on) and that's about it.
>
> > > > So, the first click of the DIV = "Change BG to 'green', update DB
> > > > field to 'XXX'"
> > > > the second click of the DIV = "Change the BG to 'aqua', update DB
> > > > field to 'YYY'"
> > > > the third click ... etc
>
> > > > Know what I mean?
>
> > > > On Oct 22, 6:04 pm, mkmanning  wrote:
>
> > > > > Well, if you just want to loop through the array to change the
> > > > > background color, you don't really need toggle then. Try this:
>
> > > > >  $("#item_list > li > div > a").click(function(){
> > > > >   var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
> > > > > 255)','rgb(128, 0, 128)'],
> > > > >   bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
> > > > >   $(this).css('background-color',arrValues[bgcolor===arrValues.length?
> > > > > 0:bgcolor]);
>
> > > > > });
>
> > > > > disclaimer: just wrote it inside Firebug's console, so haven't tested
> > > > > it outside that...
>
> > > > > On Oct 21, 10:14 pm, The Danny Bos  wrote:
>
> > > > > > Thanks, had a good read, figured it out in part.
> > > > > > Now I'm stuck trying to introduce an array to do my bidding ...
> > > > > > Example below.
>
> > > > > > The array is an example of how I want to loop through to use those
> > > > > > values.
> > > > > > Underneath is the perfect code for clicking an Anchor and changing 
> > > > > > its
> > > > > > BGcolour differently each time.
>
> > > > > > Any ideas?
>
> > > > > > $(document).ready(
> > > > > >         function(){
> > > > > >                 var arrValues = ['green','aqua','blue','purple'];
>
> > > > > >                 $("#item_list > li > div > a").toggle(
> > > > > >                 function(){
> > > > > >                         $(this).css('background-color', 'green');
> > > > > >                 }, function() {
> > > > > >                         $(this).css('background-color', 'aqua');
> > > > > >                 }, function() {
> > > > > >                         $(this).css('background-color', 'blue');
> > > > > >                 }, function() {
> > > > > >                         $(this).css('background-color', 'purple');
> > > > > >                 });
>
> > > > > > });
>
> > > > > > On Oct 22, 3:46 am, mkmanning  wrote:
>
> > > > > > > .toggle() allows you to rotate through multiple functions, you 
> > > > > > > might
> > > > > > > want to check it out in the 
> > > > > > > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > > > > > > On Oct 21, 2:58 am, The Danny Bos  wrote:
>
> > > > > > > > I've got one for ya, JQuery and Ajax.
>
> > > > > > > > I want to have a button image, let's stay it's inactive state 
> > > > > > > > it's a
> > > > > > > > grey circle, when someone clicks it once, it'd change to a blue 
> > > > > > > > circle
> > > > > > > > (update associated DB field to "blue"), click it again and it 
> > > > > > > > becomes
> > > > > > > > a red circle (update the DB field to "red") and so on. So users 
> > > > > > > > keep
> > > > > > > > clicking until they get the right color, then move on to the 
> > > > > > > > next
> > > > > > > > one.
>
> > > > > > > > I've seen something similar in Google where you can star emails 
> > > > > > > > with
> > > > > > > > different stars.
>
> > > > > > > > Any idea how you'd do this?
> > > > > > > > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread mkmanning

Something like this (untested):

var arrValues = ['c1','c2','c3','c3'],
cnameIndex = $.inArray(this.className,arrValues)+1;
this.className = cnameIndex===arrValues.length?0: cnameIndex ];

if you can live with only one classname, otherwise you'll have to add
code to remove the old classname from arrValues and then add the new
class with addClass.

Basically all this is doing is getting the current value of a given
property, such as background-color, finding its index in the arrValues
array, incrementing that by one and then setting the new value to the
element in the array with the incremented index. If the index is at
the end of the array, it resets to 0.

On Oct 22, 4:39 am, The Danny Bos  wrote:
> Thanks so much man,
> That'll work well ... One more thing, how would I change it to point
> to classes instead of direct colours?
>
> var arrValues = ['c1','c2','c3','c3'],
>
> Thanks again,
>
> On Oct 22, 6:27 pm, mkmanning  wrote:
>
>
>
> > Yeah, the snippet I wrote updates the color; you can add an ajax call
> > to update your db as well, if the value your updating in the db is the
> > color, or else the value is in an array that's indexed the same.
>
> > On Oct 22, 12:10 am, The Danny Bos  wrote:
>
> > > For each click of the DIV I'm hoping to change the BackgroundColor,
> > > make some updates in the Database (depending on which array selection
> > > it's on) and that's about it.
>
> > > So, the first click of the DIV = "Change BG to 'green', update DB
> > > field to 'XXX'"
> > > the second click of the DIV = "Change the BG to 'aqua', update DB
> > > field to 'YYY'"
> > > the third click ... etc
>
> > > Know what I mean?
>
> > > On Oct 22, 6:04 pm, mkmanning  wrote:
>
> > > > Well, if you just want to loop through the array to change the
> > > > background color, you don't really need toggle then. Try this:
>
> > > >  $("#item_list > li > div > a").click(function(){
> > > >   var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
> > > > 255)','rgb(128, 0, 128)'],
> > > >   bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
> > > >   $(this).css('background-color',arrValues[bgcolor===arrValues.length?
> > > > 0:bgcolor]);
>
> > > > });
>
> > > > disclaimer: just wrote it inside Firebug's console, so haven't tested
> > > > it outside that...
>
> > > > On Oct 21, 10:14 pm, The Danny Bos  wrote:
>
> > > > > Thanks, had a good read, figured it out in part.
> > > > > Now I'm stuck trying to introduce an array to do my bidding ...
> > > > > Example below.
>
> > > > > The array is an example of how I want to loop through to use those
> > > > > values.
> > > > > Underneath is the perfect code for clicking an Anchor and changing its
> > > > > BGcolour differently each time.
>
> > > > > Any ideas?
>
> > > > > $(document).ready(
> > > > >         function(){
> > > > >                 var arrValues = ['green','aqua','blue','purple'];
>
> > > > >                 $("#item_list > li > div > a").toggle(
> > > > >                 function(){
> > > > >                         $(this).css('background-color', 'green');
> > > > >                 }, function() {
> > > > >                         $(this).css('background-color', 'aqua');
> > > > >                 }, function() {
> > > > >                         $(this).css('background-color', 'blue');
> > > > >                 }, function() {
> > > > >                         $(this).css('background-color', 'purple');
> > > > >                 });
>
> > > > > });
>
> > > > > On Oct 22, 3:46 am, mkmanning  wrote:
>
> > > > > > .toggle() allows you to rotate through multiple functions, you might
> > > > > > want to check it out in the 
> > > > > > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > > > > > On Oct 21, 2:58 am, The Danny Bos  wrote:
>
> > > > > > > I've got one for ya, JQuery and Ajax.
>
> > > > > > > I want to have a button image, let's stay it's inactive state 
> > > > > > > it's a
> > > > > > > grey circle, when someone clicks it once, it'd change to a blue 
> > > > > > > circle
> > > > > > > (update associated DB field to "blue"), click it again and it 
> > > > > > > becomes
> > > > > > > a red circle (update the DB field to "red") and so on. So users 
> > > > > > > keep
> > > > > > > clicking until they get the right color, then move on to the next
> > > > > > > one.
>
> > > > > > > I've seen something similar in Google where you can star emails 
> > > > > > > with
> > > > > > > different stars.
>
> > > > > > > Any idea how you'd do this?
> > > > > > > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread The Danny Bos


Thanks so much man,
That'll work well ... One more thing, how would I change it to point
to classes instead of direct colours?


var arrValues = ['c1','c2','c3','c3'],

Thanks again,




On Oct 22, 6:27 pm, mkmanning  wrote:
> Yeah, the snippet I wrote updates the color; you can add an ajax call
> to update your db as well, if the value your updating in the db is the
> color, or else the value is in an array that's indexed the same.
>
> On Oct 22, 12:10 am, The Danny Bos  wrote:
>
>
>
> > For each click of the DIV I'm hoping to change the BackgroundColor,
> > make some updates in the Database (depending on which array selection
> > it's on) and that's about it.
>
> > So, the first click of the DIV = "Change BG to 'green', update DB
> > field to 'XXX'"
> > the second click of the DIV = "Change the BG to 'aqua', update DB
> > field to 'YYY'"
> > the third click ... etc
>
> > Know what I mean?
>
> > On Oct 22, 6:04 pm, mkmanning  wrote:
>
> > > Well, if you just want to loop through the array to change the
> > > background color, you don't really need toggle then. Try this:
>
> > >  $("#item_list > li > div > a").click(function(){
> > >   var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
> > > 255)','rgb(128, 0, 128)'],
> > >   bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
> > >   $(this).css('background-color',arrValues[bgcolor===arrValues.length?
> > > 0:bgcolor]);
>
> > > });
>
> > > disclaimer: just wrote it inside Firebug's console, so haven't tested
> > > it outside that...
>
> > > On Oct 21, 10:14 pm, The Danny Bos  wrote:
>
> > > > Thanks, had a good read, figured it out in part.
> > > > Now I'm stuck trying to introduce an array to do my bidding ...
> > > > Example below.
>
> > > > The array is an example of how I want to loop through to use those
> > > > values.
> > > > Underneath is the perfect code for clicking an Anchor and changing its
> > > > BGcolour differently each time.
>
> > > > Any ideas?
>
> > > > $(document).ready(
> > > >         function(){
> > > >                 var arrValues = ['green','aqua','blue','purple'];
>
> > > >                 $("#item_list > li > div > a").toggle(
> > > >                 function(){
> > > >                         $(this).css('background-color', 'green');
> > > >                 }, function() {
> > > >                         $(this).css('background-color', 'aqua');
> > > >                 }, function() {
> > > >                         $(this).css('background-color', 'blue');
> > > >                 }, function() {
> > > >                         $(this).css('background-color', 'purple');
> > > >                 });
>
> > > > });
>
> > > > On Oct 22, 3:46 am, mkmanning  wrote:
>
> > > > > .toggle() allows you to rotate through multiple functions, you might
> > > > > want to check it out in the 
> > > > > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > > > > On Oct 21, 2:58 am, The Danny Bos  wrote:
>
> > > > > > I've got one for ya, JQuery and Ajax.
>
> > > > > > I want to have a button image, let's stay it's inactive state it's a
> > > > > > grey circle, when someone clicks it once, it'd change to a blue 
> > > > > > circle
> > > > > > (update associated DB field to "blue"), click it again and it 
> > > > > > becomes
> > > > > > a red circle (update the DB field to "red") and so on. So users keep
> > > > > > clicking until they get the right color, then move on to the next
> > > > > > one.
>
> > > > > > I've seen something similar in Google where you can star emails with
> > > > > > different stars.
>
> > > > > > Any idea how you'd do this?
> > > > > > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread mkmanning

Yeah, the snippet I wrote updates the color; you can add an ajax call
to update your db as well, if the value your updating in the db is the
color, or else the value is in an array that's indexed the same.

On Oct 22, 12:10 am, The Danny Bos  wrote:
> For each click of the DIV I'm hoping to change the BackgroundColor,
> make some updates in the Database (depending on which array selection
> it's on) and that's about it.
>
> So, the first click of the DIV = "Change BG to 'green', update DB
> field to 'XXX'"
> the second click of the DIV = "Change the BG to 'aqua', update DB
> field to 'YYY'"
> the third click ... etc
>
> Know what I mean?
>
> On Oct 22, 6:04 pm, mkmanning  wrote:
>
>
>
> > Well, if you just want to loop through the array to change the
> > background color, you don't really need toggle then. Try this:
>
> >  $("#item_list > li > div > a").click(function(){
> >   var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
> > 255)','rgb(128, 0, 128)'],
> >   bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
> >   $(this).css('background-color',arrValues[bgcolor===arrValues.length?
> > 0:bgcolor]);
>
> > });
>
> > disclaimer: just wrote it inside Firebug's console, so haven't tested
> > it outside that...
>
> > On Oct 21, 10:14 pm, The Danny Bos  wrote:
>
> > > Thanks, had a good read, figured it out in part.
> > > Now I'm stuck trying to introduce an array to do my bidding ...
> > > Example below.
>
> > > The array is an example of how I want to loop through to use those
> > > values.
> > > Underneath is the perfect code for clicking an Anchor and changing its
> > > BGcolour differently each time.
>
> > > Any ideas?
>
> > > $(document).ready(
> > >         function(){
> > >                 var arrValues = ['green','aqua','blue','purple'];
>
> > >                 $("#item_list > li > div > a").toggle(
> > >                 function(){
> > >                         $(this).css('background-color', 'green');
> > >                 }, function() {
> > >                         $(this).css('background-color', 'aqua');
> > >                 }, function() {
> > >                         $(this).css('background-color', 'blue');
> > >                 }, function() {
> > >                         $(this).css('background-color', 'purple');
> > >                 });
>
> > > });
>
> > > On Oct 22, 3:46 am, mkmanning  wrote:
>
> > > > .toggle() allows you to rotate through multiple functions, you might
> > > > want to check it out in the 
> > > > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > > > On Oct 21, 2:58 am, The Danny Bos  wrote:
>
> > > > > I've got one for ya, JQuery and Ajax.
>
> > > > > I want to have a button image, let's stay it's inactive state it's a
> > > > > grey circle, when someone clicks it once, it'd change to a blue circle
> > > > > (update associated DB field to "blue"), click it again and it becomes
> > > > > a red circle (update the DB field to "red") and so on. So users keep
> > > > > clicking until they get the right color, then move on to the next
> > > > > one.
>
> > > > > I've seen something similar in Google where you can star emails with
> > > > > different stars.
>
> > > > > Any idea how you'd do this?
> > > > > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread The Danny Bos


For each click of the DIV I'm hoping to change the BackgroundColor,
make some updates in the Database (depending on which array selection
it's on) and that's about it.

So, the first click of the DIV = "Change BG to 'green', update DB
field to 'XXX'"
the second click of the DIV = "Change the BG to 'aqua', update DB
field to 'YYY'"
the third click ... etc

Know what I mean?



On Oct 22, 6:04 pm, mkmanning  wrote:
> Well, if you just want to loop through the array to change the
> background color, you don't really need toggle then. Try this:
>
>  $("#item_list > li > div > a").click(function(){
>   var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
> 255)','rgb(128, 0, 128)'],
>   bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
>   $(this).css('background-color',arrValues[bgcolor===arrValues.length?
> 0:bgcolor]);
>
> });
>
> disclaimer: just wrote it inside Firebug's console, so haven't tested
> it outside that...
>
> On Oct 21, 10:14 pm, The Danny Bos  wrote:
>
>
>
> > Thanks, had a good read, figured it out in part.
> > Now I'm stuck trying to introduce an array to do my bidding ...
> > Example below.
>
> > The array is an example of how I want to loop through to use those
> > values.
> > Underneath is the perfect code for clicking an Anchor and changing its
> > BGcolour differently each time.
>
> > Any ideas?
>
> > $(document).ready(
> >         function(){
> >                 var arrValues = ['green','aqua','blue','purple'];
>
> >                 $("#item_list > li > div > a").toggle(
> >                 function(){
> >                         $(this).css('background-color', 'green');
> >                 }, function() {
> >                         $(this).css('background-color', 'aqua');
> >                 }, function() {
> >                         $(this).css('background-color', 'blue');
> >                 }, function() {
> >                         $(this).css('background-color', 'purple');
> >                 });
>
> > });
>
> > On Oct 22, 3:46 am, mkmanning  wrote:
>
> > > .toggle() allows you to rotate through multiple functions, you might
> > > want to check it out in the 
> > > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > > On Oct 21, 2:58 am, The Danny Bos  wrote:
>
> > > > I've got one for ya, JQuery and Ajax.
>
> > > > I want to have a button image, let's stay it's inactive state it's a
> > > > grey circle, when someone clicks it once, it'd change to a blue circle
> > > > (update associated DB field to "blue"), click it again and it becomes
> > > > a red circle (update the DB field to "red") and so on. So users keep
> > > > clicking until they get the right color, then move on to the next
> > > > one.
>
> > > > I've seen something similar in Google where you can star emails with
> > > > different stars.
>
> > > > Any idea how you'd do this?
> > > > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread mkmanning

Well, if you just want to loop through the array to change the
background color, you don't really need toggle then. Try this:

 $("#item_list > li > div > a").click(function(){
  var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
255)','rgb(128, 0, 128)'],
  bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
  $(this).css('background-color',arrValues[bgcolor===arrValues.length?
0:bgcolor]);
});

disclaimer: just wrote it inside Firebug's console, so haven't tested
it outside that...

On Oct 21, 10:14 pm, The Danny Bos  wrote:
> Thanks, had a good read, figured it out in part.
> Now I'm stuck trying to introduce an array to do my bidding ...
> Example below.
>
> The array is an example of how I want to loop through to use those
> values.
> Underneath is the perfect code for clicking an Anchor and changing its
> BGcolour differently each time.
>
> Any ideas?
>
> $(document).ready(
>         function(){
>                 var arrValues = ['green','aqua','blue','purple'];
>
>                 $("#item_list > li > div > a").toggle(
>                 function(){
>                         $(this).css('background-color', 'green');
>                 }, function() {
>                         $(this).css('background-color', 'aqua');
>                 }, function() {
>                         $(this).css('background-color', 'blue');
>                 }, function() {
>                         $(this).css('background-color', 'purple');
>                 });
>
> });
>
> On Oct 22, 3:46 am, mkmanning  wrote:
>
>
>
> > .toggle() allows you to rotate through multiple functions, you might
> > want to check it out in the 
> > docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> > On Oct 21, 2:58 am, The Danny Bos  wrote:
>
> > > I've got one for ya, JQuery and Ajax.
>
> > > I want to have a button image, let's stay it's inactive state it's a
> > > grey circle, when someone clicks it once, it'd change to a blue circle
> > > (update associated DB field to "blue"), click it again and it becomes
> > > a red circle (update the DB field to "red") and so on. So users keep
> > > clicking until they get the right color, then move on to the next
> > > one.
>
> > > I've seen something similar in Google where you can star emails with
> > > different stars.
>
> > > Any idea how you'd do this?
> > > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-21 Thread The Danny Bos


Thanks, had a good read, figured it out in part.
Now I'm stuck trying to introduce an array to do my bidding ...
Example below.

The array is an example of how I want to loop through to use those
values.
Underneath is the perfect code for clicking an Anchor and changing its
BGcolour differently each time.

Any ideas?

$(document).ready(
function(){
var arrValues = ['green','aqua','blue','purple'];

$("#item_list > li > div > a").toggle(
function(){
$(this).css('background-color', 'green');
}, function() {
$(this).css('background-color', 'aqua');
}, function() {
$(this).css('background-color', 'blue');
}, function() {
$(this).css('background-color', 'purple');
});
});




On Oct 22, 3:46 am, mkmanning  wrote:
> .toggle() allows you to rotate through multiple functions, you might
> want to check it out in the 
> docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...
>
> On Oct 21, 2:58 am, The Danny Bos  wrote:
>
>
>
> > I've got one for ya, JQuery and Ajax.
>
> > I want to have a button image, let's stay it's inactive state it's a
> > grey circle, when someone clicks it once, it'd change to a blue circle
> > (update associated DB field to "blue"), click it again and it becomes
> > a red circle (update the DB field to "red") and so on. So users keep
> > clicking until they get the right color, then move on to the next
> > one.
>
> > I've seen something similar in Google where you can star emails with
> > different stars.
>
> > Any idea how you'd do this?
> > It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-21 Thread mkmanning

.toggle() allows you to rotate through multiple functions, you might
want to check it out in the docs: 
http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...

On Oct 21, 2:58 am, The Danny Bos  wrote:
> I've got one for ya, JQuery and Ajax.
>
> I want to have a button image, let's stay it's inactive state it's a
> grey circle, when someone clicks it once, it'd change to a blue circle
> (update associated DB field to "blue"), click it again and it becomes
> a red circle (update the DB field to "red") and so on. So users keep
> clicking until they get the right color, then move on to the next
> one.
>
> I've seen something similar in Google where you can star emails with
> different stars.
>
> Any idea how you'd do this?
> It's got me stumped.


[jQuery] Re: click function populating value in a hidden field

2009-10-01 Thread Chuk

Works like a charm!  Thanks so much!  :)


[jQuery] Re: click function populating value in a hidden field

2009-10-01 Thread Chuk

Works like a charm!  Thanks so much!  :)


[jQuery] Re: click function populating value in a hidden field

2009-10-01 Thread Chuk

Works like a charm!  Thanks so much!  :)


[jQuery] Re: click function populating value in a hidden field

2009-10-01 Thread James

Suppose your rows looked like this:

text
text
text

$("tr").click(function () {
$(".clicked").removeClass("clicked");
$(this).addClass("clicked");

var row_id = this.id.split('_')[1];  // e.g. 2
$("#hiddenField").val(row_id);  // hiddenField is the ID of the
hidden field
});


On Oct 1, 9:48 am, Chuk  wrote:
> Hi.  I have a table set up with a .click() function on each row so
> that if it is clicked on, a class is added to the row thus changing
> the background, etc.  I was wondering if there was is a way to take
> the id of the row that was clicked and populate a hidden field with
> it.  What would I need to include in my .click() function for this to
> work?
>
> Here is my current one:
> $("tr").click(function () {
>     $(".clicked").removeClass("clicked");
>     $(this).addClass("clicked");
>
> });
>
>


[jQuery] Re: .click() fires my callback more than once

2009-09-25 Thread allenm541

I've run into this problem many times as well.  The issue is that your
click function is being bound more than once.  To fix it, use
the .unbind() method.  .unbind() without any parameters will unbind
everything bound to that element, including your .click() function.
However, if you wish to unbind only the click() function and nothing
else, then use .unbind('click').  Here's what your code may look like:

$('#delete').click(function() {
confirmAction('Weet je zeker dat je de geselecteerde
pagina\'s wiltverwijderen?', 'destroy');
$(this).unbind();
});

Notice the .unbind() at the end.  This will prevent the bound .click()
function from stacking upon itself in future events.

See also:  http://docs.jquery.com/Events/unbind



On Sep 24, 4:26 am, Fabdrol  wrote:
> Hi guys,
>
> I'm facing this little problem, I've got a button toolbar, and users
> can select rows in a table. When they have selected some row's, they
> can click one of the buttons, and it invokes a callback.
>
> Problem is, when I click the first time, there's nothing wrong. But
> when I click the second time, it fires the callback two times, when I
> click the third time it fires the callback three times, and so on.
> That's a big problem, since the button is used to delete a page, and
> obviously it should delete it only once, since the AJAX would return
> an error ortherwise.
>
> The code is seperated in three blocks, first the the onclick on the
> button object, which invokes a function called confirmAction, taking
> to parameters. [1], a message for the users, [2] the name of the
> callback function. When the confirmation is confirmed, the
> confirmAction function calls the callback. As said before, when I
> click #delete once, it behaves like expected. But when I click the
> second time (without refresh) it runs the callback function twice,
> third time thrice, and so on.
>
> Below is my code...
>
> Thanks in advance!
>
> the onclick on the button object
> [code]
>         $('#delete').click(function() {
>                 confirmAction('Weet je zeker dat je de geselecteerde 
> pagina\'s wilt
> verwijderen?', 'destroy');
>         });
> [/code]
>
> the confirmation (global for my app, that's why callback is an
> parameter)
> [code]
> var confirmAction = function(msg, callback) {
>         var context = $('#confirmAction');
>         $('p.msg', context).html(msg);
>
>         $.blockUI({
>                 message: context,
>                 css: {
>                         border: 'none',
>                 padding: '15px',
>                 backgroundColor: '#000',
>                 '-webkit-border-radius': '10px',
>                 '-moz-border-radius': '10px',
>                 color: '#fff'
>                 }
>         });
>
>         $('#confirmYes').click(function() {
>                 $.unblockUI();
>                 base[callback](true);
>                 // [callback] is the function name, (true) the
> parameter.
>                 // base is global this cashed
>         });
>
>         $('#confirmNo').click(function() {
>                 $.unblockUI();
>                 return false;
>         });}
>
> [/code]
>
> the callback:
> [code]
> var destroy = function(yesno) {
>         var arr = new Array();
>
>         if(yesno == true) {
>                 $('input.do').each(function() {
>                         if($(this).attr('checked') == true) {
>                                 arr.push($(this).val());
>                         }
>                 });
>
>                 console.log(arr);
>         }};
>
> [/code]


[jQuery] Re: .click() fires my callback more than once

2009-09-24 Thread Liam Potter


probably because you have click handlers inside the confirmAction 
function, which is run on click itself.

Fabdrol wrote:

Hi guys,

I'm facing this little problem, I've got a button toolbar, and users
can select rows in a table. When they have selected some row's, they
can click one of the buttons, and it invokes a callback.

Problem is, when I click the first time, there's nothing wrong. But
when I click the second time, it fires the callback two times, when I
click the third time it fires the callback three times, and so on.
That's a big problem, since the button is used to delete a page, and
obviously it should delete it only once, since the AJAX would return
an error ortherwise.

The code is seperated in three blocks, first the the onclick on the
button object, which invokes a function called confirmAction, taking
to parameters. [1], a message for the users, [2] the name of the
callback function. When the confirmation is confirmed, the
confirmAction function calls the callback. As said before, when I
click #delete once, it behaves like expected. But when I click the
second time (without refresh) it runs the callback function twice,
third time thrice, and so on.

Below is my code...

Thanks in advance!

the onclick on the button object
[code]
$('#delete').click(function() {
confirmAction('Weet je zeker dat je de geselecteerde pagina\'s 
wilt
verwijderen?', 'destroy');
});
[/code]

the confirmation (global for my app, that's why callback is an
parameter)
[code]
var confirmAction = function(msg, callback) {
var context = $('#confirmAction');
$('p.msg', context).html(msg);

$.blockUI({
message: context,
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
color: '#fff'
}
});

$('#confirmYes').click(function() {
$.unblockUI();
base[callback](true);
// [callback] is the function name, (true) the
parameter.
// base is global this cashed
});

$('#confirmNo').click(function() {
$.unblockUI();
return false;
});
}
[/code]

the callback:
[code]
var destroy = function(yesno) {
var arr = new Array();

if(yesno == true) {
$('input.do').each(function() {
if($(this).attr('checked') == true) {
arr.push($(this).val());
}
});

console.log(arr);
}
};
[/code]
  




[jQuery] Re: click a button returned by ajax

2009-09-09 Thread Carlos Santos

function live was what I needed.
But now another question.
it's possible to make a POSTwith AJAX, via a button also created with
AJAX, and store the return in a CONTAINER that does not exist in the
DOM, but must exist when the POST is done?

I.E.

/*Action on a button that still exist in the DOM*/
$('#BtMoreDefeito').live("click", function(){
$.post(
'more_defeito.php',{
//NumDef: NumDef,
Str : $("#form-defeitos").serialize()
},
function(data){
//NumDef = new Number(NumDef + 1);

/*This ID will still exist in the DOM as well.*/

//$('#NumItem').val(NumDef);
var htmlStr = $('#result_defeitos').html();

/*This ID will still exist in the DOM as well.*/

$('#result_defeitos').html(data);
}
);
});


[jQuery] Re: click a button returned by ajax

2009-09-08 Thread rupak mandal
Hi carlos

try to use
http://docs.jquery.com/Events/live

thanks
Rupak

On Tue, Sep 8, 2009 at 8:54 PM, Carlos Santos wrote:

>
> I have a button that do appear on my page through a post with jquery:
>
> $.post(
>'more_item.php',{
>NumItem: NumeroItem,
>Str : $("#form-itens").serialize()
>},
>function(data){
>NumeroItem = new Number(NumeroItem + 1);
>$('#NumItem').val(NumeroItem);
>var htmlStr = $('#resut_itens').html();
>$('#resut_itens').html(data);
>}
> );
>
> it returns me a clickable link:
>
> Default 
>
> I want to create a JQUERY that clicking this BtMoreDefeito execute a
> POST:
>
> $('#BtMoreDefeito').click(function(){
>$.post(
>'more_defeito.php',{
>NumDef: NumDef,
>Str :
> $("#form-defeitos").serialize()
>},
>function(data){
>NumDef = new Number(NumDef + 1);
>$('#NumItem').val(NumDef);
>var htmlStr = $('#result_defeitos').html();
>$('#result_defeitos').html(data);
>}
>);
> });
>
> but this has not worked. the latter showed that jquery is inserted in
> the index.
> the main page that calls the button.
> jquery in a home can act on an ID loaded from another file with ajax?
>


[jQuery] Re: click a button returned by ajax

2009-09-08 Thread MorningZ

There's no reason why this shouldn't work... remember you cannot wire
an event to something that isn't on the DOM unless you:

(1) use the ".live()" functionality of jQuery (http://docs.jquery.com/
Events/live#typefn)

or

(2) do it after it is in the DOM, which my code shows below

$.post(
'more_item.php',
{ NumItem: NumeroItem, Str : $("#form-itens").serialize() },
function(data){
NumeroItem = new Number(NumeroItem + 1);
 $('#NumItem').val(NumeroItem);
 var htmlStr = $('#resut_itens').html();
 $('#resut_itens').html(data);
 //Wire up anchor to do something
 $("#BtMoreDefeito").click(function() {
   // Do something
 });
}
);



[jQuery] Re: Click event not working?

2009-08-27 Thread James

Could you show us what your animate_next() function looks like?

On Aug 26, 3:04 pm, Kris S  wrote:
> I'm trying to execute a function "animate_next()" when a "div" element
> is clicked, but it isn't working. Here is what it looks like..
>
> $('#playground').click(function(){animate_next();});
>
> If I put..
>
> $('#playground').ready(function(){animate_next();});
>
> ..then it will work fine.
>
> Here is the "div" element on the page..
>
> 


[jQuery] Re: Click event not working?

2009-08-27 Thread Cesar Sanz


mmm.. try this..

Put a border to your div, let's say border: 10px, then click the border to 
see what happen..



- Original Message - 
From: "Kris S" 

To: "jQuery (English)" 
Sent: Wednesday, August 26, 2009 7:04 PM
Subject: [jQuery] Click event not working?




I'm trying to execute a function "animate_next()" when a "div" element
is clicked, but it isn't working. Here is what it looks like..

$('#playground').click(function(){animate_next();});

If I put..

$('#playground').ready(function(){animate_next();});

..then it will work fine.

Here is the "div" element on the page..

 




[jQuery] Re: Click Binding not Working

2009-08-25 Thread Richard D. Worth
You need to use the ID selector (#):
$('#btnInput').click(showVal);
$('#btnInput').bind('click', showVal);

- Richard

On Wed, Aug 26, 2009 at 2:18 AM, S2  wrote:

>
> I have this code that works:
>
> var btnInput= document.getElementById('btnInput');
> btnInput.addEventListener("click", showVal, true);
>
> Why doesn't this work?
>
> $('btnInput').click(showVal);
> $('btnInput').bind('click', showVal);


[jQuery] Re: click-event-handler for dynamically created a-elements?

2009-08-20 Thread ak732

There are a lot of ways to do this, here are a couple:

$("#div99").append("I am in div99").click
(function(){alert("hello world");});

$("").attr({id:"alnDiv99", href:"#"}).text("I am in div99").click
(function(){alert("hello world");}).appendTo("#div99");


On Aug 20, 6:42 am, Audrey A Lee  wrote:
> Hello,
>
> I've been working with jQuery about 20 hours now.
>
> I like it.
>
> I am looking for a demo of putting an a-element inside a div-element.
>
> This seems to work:
>
>   $("#div99")[0].innerHTML = "I am in div99 a>";
>
> I'd like to handle its click-event.
>
> I wrote this:
>
> $("a#aInDiv99").click(function(event){alert("hello world");});
>
> The click event does not fire when I click 'aInDiv99'
>
> Is there a recipe for writing a click-event-handler for dynamically
> created a-elements?
>
> Oh, here is my world:
>   - jquery-1.3.2.js
>   - Safari 4.0.3
>   - Firefox 3.5.2
>
> -Audrey


[jQuery] Re: click-event-handler for dynamically created a-elements?

2009-08-20 Thread ak732

You might also want to check go to http://api.jquery.com and check out
the "live" method under Events-->Live Events.

On Aug 20, 9:43 am, ak732  wrote:
> There are a lot of ways to do this, here are a couple:
>
> $("#div99").append("I am in div99").click
> (function(){alert("hello world");});
>
> $("").attr({id:"alnDiv99", href:"#"}).text("I am in div99").click
> (function(){alert("hello world");}).appendTo("#div99");
>
> On Aug 20, 6:42 am, Audrey A Lee  wrote:
>
> > Hello,
>
> > I've been working with jQuery about 20 hours now.
>
> > I like it.
>
> > I am looking for a demo of putting an a-element inside a div-element.
>
> > This seems to work:
>
> >   $("#div99")[0].innerHTML = "I am in div99 > a>";
>
> > I'd like to handle its click-event.
>
> > I wrote this:
>
> > $("a#aInDiv99").click(function(event){alert("hello world");});
>
> > The click event does not fire when I click 'aInDiv99'
>
> > Is there a recipe for writing a click-event-handler for dynamically
> > created a-elements?
>
> > Oh, here is my world:
> >   - jquery-1.3.2.js
> >   - Safari 4.0.3
> >   - Firefox 3.5.2
>
> > -Audrey


[jQuery] Re: Click() Not Working

2009-08-14 Thread James

Just to clarify that further, click() on a  doesn't perform a mouse
click on a link and follow through.
It calls the onclick event attached to the  elements, which you
don't have set, so it does nothing.


On Aug 14, 4:08 pm, "Richard D. Worth"  wrote:
> It doesn't work to call .click() on an A, if you want to navigate a link's
> href. Instead:
>
> window.location = $("td a.menu:contains('Main')").attr('href');
>
> - Richard
>
> On Fri, Aug 14, 2009 at 7:32 PM, S2  wrote:
>
> > http://www.w3.org/
> > TR/html4/strict.dtd">
> > 
> > 
> >   
> >   
> >   
> >   
> >   
> >      $(function(){
> >          $("td a.menu:contains('Main')").click();
> >      });
> >   
> > 
> > 
> >   
> >      
> >         
> >         
> >         
> >         
> >      
> >      
> >         
> >            Main
> >         
> >         
> >         
> >      
> >   
> > 
> > 
>
> > On Aug 13, 6:32 pm, Jules  wrote:
> > > $("td a.menu:contains('Main')").click() should work. Can you post the
> > > html?
>
> > > On Aug 14, 4:48 am, S2  wrote:
>
> > > > This doesn't work in IE or Firefox:
>
> > > > $("td a.menu:contains('Main')").click();
>
> > > > This works in IE:
>
> > > > $("td a.menu:contains('Main')")[0].click();
>
> > > > $("td a.menu:contains('Main')").length is 1
>
> > > > What am I doing wrong?
>
>


[jQuery] Re: Click() Not Working

2009-08-14 Thread Richard D. Worth
It doesn't work to call .click() on an A, if you want to navigate a link's
href. Instead:

window.location = $("td a.menu:contains('Main')").attr('href');

- Richard

On Fri, Aug 14, 2009 at 7:32 PM, S2  wrote:

>
> http://www.w3.org/
> TR/html4/strict.dtd">
> 
> 
>   
>   
>   
>   
>   
>  $(function(){
>  $("td a.menu:contains('Main')").click();
>  });
>   
> 
> 
>   
>  
> 
> 
> 
> 
>  
>  
> 
>Main
> 
> 
> 
>  
>   
> 
> 
>
> On Aug 13, 6:32 pm, Jules  wrote:
> > $("td a.menu:contains('Main')").click() should work. Can you post the
> > html?
> >
> > On Aug 14, 4:48 am, S2  wrote:
> >
> > > This doesn't work in IE or Firefox:
> >
> > > $("td a.menu:contains('Main')").click();
> >
> > > This works in IE:
> >
> > > $("td a.menu:contains('Main')")[0].click();
> >
> > > $("td a.menu:contains('Main')").length is 1
> >
> > > What am I doing wrong?
>


[jQuery] Re: Click() Not Working

2009-08-14 Thread S2

http://www.w3.org/
TR/html4/strict.dtd">


   
   
   
   
   
  $(function(){
  $("td a.menu:contains('Main')").click();
  });
   


   
  
 
 
 
 
  
  
 
Main
 
 
 
  
   



On Aug 13, 6:32 pm, Jules  wrote:
> $("td a.menu:contains('Main')").click() should work. Can you post the
> html?
>
> On Aug 14, 4:48 am, S2  wrote:
>
> > This doesn't work in IE or Firefox:
>
> > $("td a.menu:contains('Main')").click();
>
> > This works in IE:
>
> > $("td a.menu:contains('Main')")[0].click();
>
> > $("td a.menu:contains('Main')").length is 1
>
> > What am I doing wrong?


[jQuery] Re: Click() Not Working

2009-08-13 Thread Jules

$("td a.menu:contains('Main')").click() should work. Can you post the
html?

On Aug 14, 4:48 am, S2  wrote:
> This doesn't work in IE or Firefox:
>
> $("td a.menu:contains('Main')").click();
>
> This works in IE:
>
> $("td a.menu:contains('Main')")[0].click();
>
> $("td a.menu:contains('Main')").length is 1
>
> What am I doing wrong?


[jQuery] Re: Click event to load a new page

2009-08-06 Thread Simon

This is something that was bothering me too, and I came to the same
conclusion. How is this for SEO though? Redirecting with Javascript
that is? Does it recognize the link?

Cheers,
Simon

On Aug 6, 3:52 pm, "paul.mac"  wrote:
> Thanks guys - came to the same conclusion shortly after posting the
> question.
>
> Thanks
>
> Paul
>
> On Aug 6, 7:52 pm, "Richard D. Worth"  wrote:
>
> > Use
> > window.location
> > = "index.php?whichPage=slider&whichAct=0&subPage=mixnmingle";
> > - Richard
>
> > On Thu, Aug 6, 2009 at 2:35 PM, paul.mac 
> > wrote:
>
> > > I want to add a click function to an image to laod a new page
>
> > > Tried this but it doesn't work
>
> > > $("#i4").click(function(){
> > >    $(document).attr("href","index.php?
> > > whichPage=slider&whichAct=0&subPage=mixnmingle");
> > >    });
>
> > > The whichAct variable in the query string gets changed, which is why
> > > it isn't just a static ...
>
> > > Any suggestions?
>
> > > Thanks
>
> > > Paul


[jQuery] Re: Click event to load a new page

2009-08-06 Thread paul.mac

Thanks guys - came to the same conclusion shortly after posting the
question.

Thanks

Paul


On Aug 6, 7:52 pm, "Richard D. Worth"  wrote:
> Use
> window.location
> = "index.php?whichPage=slider&whichAct=0&subPage=mixnmingle";
> - Richard
>
> On Thu, Aug 6, 2009 at 2:35 PM, paul.mac 
> wrote:
>
>
>
> > I want to add a click function to an image to laod a new page
>
> > Tried this but it doesn't work
>
> > $("#i4").click(function(){
> >    $(document).attr("href","index.php?
> > whichPage=slider&whichAct=0&subPage=mixnmingle");
> >    });
>
> > The whichAct variable in the query string gets changed, which is why
> > it isn't just a static ...
>
> > Any suggestions?
>
> > Thanks
>
> > Paul


[jQuery] Re: Click event to load a new page

2009-08-06 Thread Richard D. Worth
Use
window.location
= "index.php?whichPage=slider&whichAct=0&subPage=mixnmingle";
- Richard

On Thu, Aug 6, 2009 at 2:35 PM, paul.mac wrote:

>
> I want to add a click function to an image to laod a new page
>
> Tried this but it doesn't work
>
> $("#i4").click(function(){
>$(document).attr("href","index.php?
> whichPage=slider&whichAct=0&subPage=mixnmingle");
>});
>
> The whichAct variable in the query string gets changed, which is why
> it isn't just a static ...
>
> Any suggestions?
>
> Thanks
>
> Paul
>


[jQuery] Re: Click event to load a new page

2009-08-06 Thread James

Do you mean that when someone clicks on an image, it just goes to a
different page? (Similar to a normal  tag around an image.)
If so:

$("#i4").click(function() {
document.location.href = 'index.php?
whichPage=slider&whichAct=0&subPage=mixnmingle';
});

Or did you mean "load" an external page within the current page?
In which case you can use the $.load() jQuery ajax function.


On Aug 6, 8:35 am, "paul.mac"  wrote:
> I want to add a click function to an image to laod a new page
>
> Tried this but it doesn't work
>
> $("#i4").click(function(){
>     $(document).attr("href","index.php?
> whichPage=slider&whichAct=0&subPage=mixnmingle");
>     });
>
> The whichAct variable in the query string gets changed, which is why
> it isn't just a static ...
>
> Any suggestions?
>
> Thanks
>
> Paul


[jQuery] Re: click treeview and then jqgrid refresh?

2009-07-20 Thread Orcun Avsar

You can use:
$("#grid_id").trigger("reloadGrid");

it reloads grid with grid params that may be changed by browser user
( sorting name, page number), so if you want a full refresh or need
changed options on grid , you may need to use something like this:
$("#grid_id").setGridParam(default_parameters).trigger("reloadGrid");

it's described on documentation, see: "Basic Grids" > "Methods"
section

On Jul 2, 5:38 pm, ljnet  wrote:
> how to let the jqgrid refresh? without page reloading.
> does jqgrid have such a method? how to call it?
>
> Thanks in advance.


[jQuery] Re: .click doesn't seem to respond to elements added with jQuery

2009-07-16 Thread borgsquad


try to use the .live method with the click listener


blcArmadillo wrote:
> 
> I'm working on creating a little suggestion/autocomplete code for form
> fields.
> 
> Here is the code I currently have written:
> $(document).ready(function() {
>   $("#city").keyup(function() {
>   
> $.getJSON("http://iburris.ath.cx/autosuggest/city/"+$("#city").val(),
> function(data) {
>   if (data == "") {
>   $("#results").css("display", "none");
>   } else {
>   results = "";
>   $.each(data, function(i, item) {
>   results += " class=\"autosuggest_results_item\"
> title=\""+item.city+", "+item.state+"\">"+item.city+",
> "+item.state+"";
>   });
>   results += "";
>   $("#results").html(results);
>   $("#results").css("display", "block");
>   }
>   });
>   });
>   
>   $(".autosuggest_results_item").click(function() {
>$("#city").val($(this).attr("title"));
>});
> });
> 
> Now if I just put in my html something like:
> Foo
> 
> Everything works fine and when I click on the text Foo the form field
> value is set to foo. But, when I try clicking on a word added to the page
> by the keyup part of my code above it doesn't work. Even though if you
> look at the source everything is the same. Hopefully you guys understand
> my problem. If not ask for clarification and I'll do my best to answer
> your questions. Thanks for your help.
> 

-- 
View this message in context: 
http://www.nabble.com/.click-doesn%27t-seem-to-respond-to-elements-added-with-jQuery-tp24508422s27240p24510502.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: Click events handling conflict due to prototype?

2009-06-23 Thread Steve the Canuck

Ok, I know why this is happening.  This is the issue where Ajax loaded
content is not in the jQuery DOM tree, so you have to use a non Ajax
loaded selector in order to respond to the event.

Steve

On Jun 22, 9:14 pm, Steve the Canuck  wrote:
> Thanks, yes, I should have mentioned - I do have jQuery.noConflict()
> declared at the top of each of my scripts to avoid conflicts in
> general.
>
> I've also stepped through the code in a debugger using Firebug.  I put
> a breakpoint on my selector for the anchor tag, and I see in the
> debugger that it seems to go right past the selector.
>
> But, if I put this link outside the table and run it through the
> debugger, the selector does work properly.
>
> Regards,Steve
>
> On Jun 22, 8:04 pm, Charlie  wrote:
>
> > have you tried using jQuery.noConflict();  
> > ?http://docs.jquery.com/Using_jQuery_with_Other_Libraries
> >StevetheCanuckwrote:Thanks, I tried this, but it doesn't seem to work: 
> >jQuery('.cancel_posting').click( function(e) { alert("got here"); if 
> >(!confirm("Are you sure you want to cancel this booking?")) { 
> >e.preventDefault(); } }); On Jun 22, 3:17 pm, "Cesar 
> >Sanz"wrote:Use jQuery and not $ ----- Original 
> >Message - From: "StevetheCanuck"To: "jQuery 
> >(English)"Sent: Monday, June 22, 2009 10:34 AM 
> >Subject: [jQuery] Re: Click events handling conflict due to prototype? 
> >Btw... I do have a workaround - register my click event on something outside 
> >the table, such as the body tag, and then check the original event target.  
> >I'd prefer to target just the list item and anchor though if possible. On 
> >Jun 22, 11:14 am,StevetheCanuckwrote:Hi,I have a 
> >simple list inside a table  >class="cancel_posting">  >href="/frontend_dev.php/organizer/cancel-booking/20" 
> >linkindex="18">Cancel  I have a ready event handler for click 
> >events on the anchor:$j('.cancel_posting').click( function(e) { if 
> >(!confirm("Are you sure you want to cancel this booking?")) { 
> >e.preventDefault(); } });However, this event doesn't seem to fire because 
> >the table has some prototype controls inside it.If I just copy the list 
> >outside the table as a test, it seems like the event handler works fine.I am 
> >using jquery for all my own code, but some widgets from my PHP framework 
> >(symfony) are built in prototype, so I've been using both to some extent.Any 
> >ideas about how I can rectify this?Thanks!Steve


[jQuery] Re: Click events handling conflict due to prototype?

2009-06-22 Thread Steve the Canuck

Thanks, yes, I should have mentioned - I do have jQuery.noConflict()
declared at the top of each of my scripts to avoid conflicts in
general.

I've also stepped through the code in a debugger using Firebug.  I put
a breakpoint on my selector for the anchor tag, and I see in the
debugger that it seems to go right past the selector.

But, if I put this link outside the table and run it through the
debugger, the selector does work properly.

Regards,
Steve

On Jun 22, 8:04 pm, Charlie  wrote:
> have you tried using jQuery.noConflict();  
> ?http://docs.jquery.com/Using_jQuery_with_Other_Libraries
> Steve the Canuck wrote:Thanks, I tried this, but it doesn't seem to work: 
> jQuery('.cancel_posting').click( function(e) { alert("got here"); if 
> (!confirm("Are you sure you want to cancel this booking?")) { 
> e.preventDefault(); } }); On Jun 22, 3:17 pm, "Cesar 
> Sanz"wrote:Use jQuery and not $ - Original 
> Message - From: "Steve the Canuck"To: "jQuery 
> (English)"Sent: Monday, June 22, 2009 10:34 AM 
> Subject: [jQuery] Re: Click events handling conflict due to prototype? Btw... 
> I do have a workaround - register my click event on something outside the 
> table, such as the body tag, and then check the original event target.  I'd 
> prefer to target just the list item and anchor though if possible. On Jun 22, 
> 11:14 am, Steve the Canuckwrote:Hi,I have a simple 
> list inside a table   href="/frontend_dev.php/organizer/cancel-booking/20" 
> linkindex="18">Cancel  I have a ready event handler for click 
> events on the anchor:$j('.cancel_posting').click( function(e) { if 
> (!confirm("Are you sure you want to cancel this booking?")) { 
> e.preventDefault(); } });However, this event doesn't seem to fire because the 
> table has some prototype controls inside it.If I just copy the list outside 
> the table as a test, it seems like the event handler works fine.I am using 
> jquery for all my own code, but some widgets from my PHP framework (symfony) 
> are built in prototype, so I've been using both to some extent.Any ideas 
> about how I can rectify this?Thanks! Steve


[jQuery] Re: Click events handling conflict due to prototype?

2009-06-22 Thread Charlie





have you tried using jQuery.noConflict();  ?

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Steve the Canuck wrote:

  Thanks, I tried this, but it doesn't seem to work:

	jQuery('.cancel_posting').click( function(e) {
		alert("got here");
		if (!confirm("Are you sure you want to cancel this booking?")) {
			e.preventDefault();
		}
	});


On Jun 22, 3:17 pm, "Cesar Sanz"  wrote:
  
  
Use jQuery and not $

- Original Message -
From: "Steve the Canuck" 
To: "jQuery (English)" 
Sent: Monday, June 22, 2009 10:34 AM
Subject: [jQuery] Re: Click events handling conflict due to prototype?

Btw... I do have a workaround - register my click event on something
outside the table, such as the body tag, and then check the original
event target.  I'd prefer to target just the list item and anchor
though if possible.

On Jun 22, 11:14 am, Steve the Canuck  wrote:


  Hi,
  


  I have a simple list inside a table
  


  

Cancel


  


  I have a ready event handler for click events on the anchor:
  


  $j('.cancel_posting').click( function(e) {
if (!confirm("Are you sure you want to cancel this booking?")) {
e.preventDefault();
}
});
  


  However, this event doesn't seem to fire because the table has some
prototype controls inside it.
  


  If I just copy the list outside the table as a test, it seems like the
event handler works fine.
  


  I am using jquery for all my own code, but some widgets from my PHP
framework (symfony) are built in prototype, so I've been using both to
some extent.
  


  Any ideas about how I can rectify this?
  


  Thanks!
Steve
  

  
  
  






[jQuery] Re: Click events handling conflict due to prototype?

2009-06-22 Thread Steve the Canuck

Thanks, I tried this, but it doesn't seem to work:

jQuery('.cancel_posting').click( function(e) {
alert("got here");
if (!confirm("Are you sure you want to cancel this booking?")) {
e.preventDefault();
}
});


On Jun 22, 3:17 pm, "Cesar Sanz"  wrote:
> Use jQuery and not $
>
> - Original Message -
> From: "Steve the Canuck" 
> To: "jQuery (English)" 
> Sent: Monday, June 22, 2009 10:34 AM
> Subject: [jQuery] Re: Click events handling conflict due to prototype?
>
> Btw... I do have a workaround - register my click event on something
> outside the table, such as the body tag, and then check the original
> event target.  I'd prefer to target just the list item and anchor
> though if possible.
>
> On Jun 22, 11:14 am, Steve the Canuck  wrote:
> > Hi,
>
> > I have a simple list inside a table
>
> > 
> > 
> >  > linkindex="18">Cancel
> > 
> > 
>
> > I have a ready event handler for click events on the anchor:
>
> > $j('.cancel_posting').click( function(e) {
> > if (!confirm("Are you sure you want to cancel this booking?")) {
> > e.preventDefault();
> > }
> > });
>
> > However, this event doesn't seem to fire because the table has some
> > prototype controls inside it.
>
> > If I just copy the list outside the table as a test, it seems like the
> > event handler works fine.
>
> > I am using jquery for all my own code, but some widgets from my PHP
> > framework (symfony) are built in prototype, so I've been using both to
> > some extent.
>
> > Any ideas about how I can rectify this?
>
> > Thanks!
> > Steve


[jQuery] Re: Click events handling conflict due to prototype?

2009-06-22 Thread Cesar Sanz

Use jQuery and not $

- Original Message - 
From: "Steve the Canuck" 
To: "jQuery (English)" 
Sent: Monday, June 22, 2009 10:34 AM
Subject: [jQuery] Re: Click events handling conflict due to prototype?



Btw... I do have a workaround - register my click event on something
outside the table, such as the body tag, and then check the original
event target.  I'd prefer to target just the list item and anchor
though if possible.

On Jun 22, 11:14 am, Steve the Canuck  wrote:
> Hi,
>
> I have a simple list inside a table
>
> 
> 
>  linkindex="18">Cancel
> 
> 
>
> I have a ready event handler for click events on the anchor:
>
> $j('.cancel_posting').click( function(e) {
> if (!confirm("Are you sure you want to cancel this booking?")) {
> e.preventDefault();
> }
> });
>
> However, this event doesn't seem to fire because the table has some
> prototype controls inside it.
>
> If I just copy the list outside the table as a test, it seems like the
> event handler works fine.
>
> I am using jquery for all my own code, but some widgets from my PHP
> framework (symfony) are built in prototype, so I've been using both to
> some extent.
>
> Any ideas about how I can rectify this?
>
> Thanks!
> Steve


[jQuery] Re: Click events handling conflict due to prototype?

2009-06-22 Thread Steve the Canuck

Btw... I do have a workaround - register my click event on something
outside the table, such as the body tag, and then check the original
event target.  I'd prefer to target just the list item and anchor
though if possible.

On Jun 22, 11:14 am, Steve the Canuck  wrote:
> Hi,
>
> I have a simple list inside a table
>
> 
> 
>  linkindex="18">Cancel
> 
> 
>
> I have a ready event handler for click events on the anchor:
>
>         $j('.cancel_posting').click( function(e) {
>                 if (!confirm("Are you sure you want to cancel this 
> booking?")) {
>                         e.preventDefault();
>                 }
>         });
>
> However, this event doesn't seem to fire because the table has some
> prototype controls inside it.
>
> If I just copy the list outside the table as a test, it seems like the
> event handler works fine.
>
> I am using jquery for all my own code, but some widgets from my PHP
> framework (symfony) are built in prototype, so I've been using both to
> some extent.
>
> Any ideas about how I can rectify this?
>
> Thanks!
> Steve


[jQuery] Re: click function on anchor element

2009-06-11 Thread Kean

Interesting! That's also the same with labeling object properties. The
label will be casted into their string representation.

asdf

$('#ya').click(function(){
   a = {};
   a[this] = 1;
   cache = this;
});

alert(a[cache.toString()]); // alerts 1

On Jun 11, 12:16 pm, Ricardo  wrote:
> Just clearing up what Pierre said: if the argument you passed to alert
> () is not a string, it's .toString() method will be called. For
> convenience, the toString on an anchor HTMLElement object returns it's
> href. Try this:
>
> $('a').get(0).toString();
> or
> $('a').click(function(){
>    alert( this.toString() );
>    return false;
>
> });
>
> "this" in your code is still an object, it's just the output of
> toString() that is different.
>
> cheers
> -- ricardo
>
> On Jun 11, 1:10 am, "bensan...@gmail.com"  wrote:
>
> > Hi all,
>
> > I'm confused as to why when I have:
>
> > $('a').click(function(){
> > alert(this);
> > return false;
>
> > });
>
> > the alert displays the URL defined in the href attribute, and not an
> > object.
>
> > Yet, if i call like say an image, it returns the object.
>
> > Thanks
> > ben


[jQuery] Re: click function on anchor element

2009-06-11 Thread Ricardo

Just clearing up what Pierre said: if the argument you passed to alert
() is not a string, it's .toString() method will be called. For
convenience, the toString on an anchor HTMLElement object returns it's
href. Try this:

$('a').get(0).toString();
or
$('a').click(function(){
   alert( this.toString() );
   return false;
});

"this" in your code is still an object, it's just the output of
toString() that is different.

cheers
-- ricardo

On Jun 11, 1:10 am, "bensan...@gmail.com"  wrote:
> Hi all,
>
> I'm confused as to why when I have:
>
> $('a').click(function(){
> alert(this);
> return false;
>
> });
>
> the alert displays the URL defined in the href attribute, and not an
> object.
>
> Yet, if i call like say an image, it returns the object.
>
> Thanks
> ben


[jQuery] Re: click function on anchor element

2009-06-11 Thread Chandan Luthra
Hi Bensanlau,

try

$('a').click(function(){
alert(*$(this)*);
return false;
});


Chandan Luthra
Intelligrape Software Pvt. Ltd.
Josh Billings
- "Every man has his follies - and often they are the most interesting
thing he has got."

On Thu, Jun 11, 2009 at 15:33, Pierre Bellan  wrote:

> Hi,
> I think that is because of the alert function.
> It needs a string and maybe for an anchor object, jquery introduces a
> toString method.
>
> With the console of firebug, there are no differences between anchor and
> images
>
> Pierre
>
>
> 2009/6/11 bensan...@gmail.com 
>
>
>> Hi all,
>>
>> I'm confused as to why when I have:
>>
>> $('a').click(function(){
>> alert(this);
>> return false;
>> });
>>
>> the alert displays the URL defined in the href attribute, and not an
>> object.
>>
>> Yet, if i call like say an image, it returns the object.
>>
>> Thanks
>> ben
>>
>
>


[jQuery] Re: click function on anchor element

2009-06-11 Thread Pierre Bellan
Hi,
I think that is because of the alert function.
It needs a string and maybe for an anchor object, jquery introduces a
toString method.

With the console of firebug, there are no differences between anchor and
images

Pierre


2009/6/11 bensan...@gmail.com 

>
> Hi all,
>
> I'm confused as to why when I have:
>
> $('a').click(function(){
> alert(this);
> return false;
> });
>
> the alert displays the URL defined in the href attribute, and not an
> object.
>
> Yet, if i call like say an image, it returns the object.
>
> Thanks
> ben
>


[jQuery] Re: Click event on dynamically-generated link

2009-06-04 Thread fredriley

Thanks to you as well for the swift reply.

On Jun 4, 4:04 pm, MorningZ  wrote:
> I'd suggest to understand why your dynamic objects are wired up,
> thoroughly read this article
>
> http://www.learningjquery.com/2008/03/working-with-events-part-1

Thanks, I'll read it carefully.

> understanding "why" is the solution of fixing your issue

Quite.

> "as even to do the simplest thing you need to fully internalise the
> whole framework"
>
> I'm not exactly sure what "internalise the whole framework" is
> supposed to mean, but I can say from personal experience that I have
> been using jQuery for a year and a half now, and i've had to go inside
> the jQuery core file *maybe* 4-5 times, and mainly just to learn what
> things were doing for my own knowledge

I mean that I have to internalise the conceptual structure of jQuery
in order to use it for the simplest things. I did initially approach
the framework as a possible timesaver, thinking that I could just copy
and adapt a few functions and save myself a lot of JS coding. Well, I
can do that, but in order to use those functions I need to understand
in depth how jQuery works, and to understand that I need a good
understanding of JS and the DOM. The answer that Waseem gave above is
a case in point - I'd never in a hundred years have found the 'live'
construct as a solution to my problem. And yes, I do have the 'hussar'
book.

Maybe it's just me - like human languages, you sometimes come across a
programming language that you really struggle to get your head around,
and jQuery is one of those for me (yes, I know it's not strictly
speaking a language but a framework). It is the dog's bollocks and no
mistake, and it is very handy to have functions which I know will work
in all browsers, and the plugins, especially the UI plugins, are
absolutely excellent and would take a year and a day to replicate in
JS and CSS. And I do appreciate all the hard work the developers and
documentors have put in. But it is not a language to dabble with, as
perhaps Mootools is - you really have to immerse yourself in jQuery to
use it, which means a large time investment at first which I wasn't
prepared for. Now that I have become a little familiar with the thing
I'm just starting to see time savings and productivity improvements,
but it's been a steep hill up to here. After all the time I've put
into it I'm now committed to it, come hell or high water ;-)

Cheers

Fred



[jQuery] Re: Click event on dynamically-generated link

2009-06-04 Thread fredriley

On Jun 4, 3:50 pm, waseem sabjee  wrote:
> $(".mylinkclass").live("click", function() {
> alert("it Worked");
>
> }):

Thanks very much for the swift and helpful reply. I'd not come across
'live' before, but looking at the docs http://docs.jquery.com/Events/live
it's plainly what I need, and it works fine :)

Cheers

Fred


[jQuery] Re: Click event on dynamically-generated link

2009-06-04 Thread MorningZ

I'd suggest to understand why your dynamic objects are wired up,
thoroughly read this article

http://www.learningjquery.com/2008/03/working-with-events-part-1

understanding "why" is the solution of fixing your issue

as for

"as even to do the simplest thing you need to fully internalise the
whole framework"

I'm not exactly sure what "internalise the whole framework" is
supposed to mean, but I can say from personal experience that I have
been using jQuery for a year and a half now, and i've had to go inside
the jQuery core file *maybe* 4-5 times, and mainly just to learn what
things were doing for my own knowledge

"and have a comprehensive in-depth understanding of Javascript and the
DOM"

That's simply not true the whole purpose of a framework like
jQuery is so the programmer *doesn't need to* comprehensively
understand JS and the DOM

for instance there's a lot of things that IE does/behaves differently,
but jQuery hides that fact from the programmer

then again, what one is trying to accomplish would have a big factor
in having to know the DOM or advanced script



On Jun 4, 10:46 am, fredriley  wrote:
> Sorry to post again to this group, but again jQuery has me stumped on
> what seems like a simple task. I've a test doc up 
> athttp://www.nottingham.ac.uk/~ntzfr/test/ajax/jquery/xml/jquery_xml3.html
> and if you click on any of the static links (class="rlo_link") you'll
> get an alert, meaning that the "$(".rlo_link").click(function()" is
> being called. Click on the "Click here" link to generate dynamic links
> and then click on those, and no alert appears. Could someone kindly
> explain why this is? I can only guess that it's something to do with
> the links being generated after the main page has loaded, in response
> to an event, but if that's the case I don't know how to access such
> dynamically-created elements and events.
>
> What I'm ultimately trying to do is read a XML file 
> (likehttp://www.nottingham.ac.uk/~ntzfr/test/ajax/jquery/xml/ulo_test1.xml)
> of link titles and URLs, then allow the user to choose one of those to
> display in an . The idea is that a teacher can select some web
> resources and display them to students behind a friendly interface. I
> could well be going the wrong way about it by using attr("src", url)
> to change the  target - should I be using load() instead, or
> taking another approach altogether?
>
> jQuery is *hard*! If not for all the wonderful plugins and my
> sheer obstinacy I'd have given up in despair ages ago, as even to do
> the simplest thing you need to fully internalise the whole framework,
> and have a comprehensive in-depth understanding of Javascript and the
> DOM. 
>
> Cheers
>
> Fred


[jQuery] Re: Click event on dynamically-generated link

2009-06-04 Thread waseem sabjee
$(".mylinkclass").live("click", function() {
alert("it Worked");
}):

if that fails try holding this script in one of the xml nodes


$(function() {
$(".mylinkclass").live("click", function() {
alert("it Worked");
}):
});


On Thu, Jun 4, 2009 at 4:46 PM, fredriley  wrote:

>
> Sorry to post again to this group, but again jQuery has me stumped on
> what seems like a simple task. I've a test doc up at
> http://www.nottingham.ac.uk/~ntzfr/test/ajax/jquery/xml/jquery_xml3.html
> and if you click on any of the static links (class="rlo_link") you'll
> get an alert, meaning that the "$(".rlo_link").click(function()" is
> being called. Click on the "Click here" link to generate dynamic links
> and then click on those, and no alert appears. Could someone kindly
> explain why this is? I can only guess that it's something to do with
> the links being generated after the main page has loaded, in response
> to an event, but if that's the case I don't know how to access such
> dynamically-created elements and events.
>
> What I'm ultimately trying to do is read a XML file (like
> http://www.nottingham.ac.uk/~ntzfr/test/ajax/jquery/xml/ulo_test1.xml
> )
> of link titles and URLs, then allow the user to choose one of those to
> display in an . The idea is that a teacher can select some web
> resources and display them to students behind a friendly interface. I
> could well be going the wrong way about it by using attr("src", url)
> to change the  target - should I be using load() instead, or
> taking another approach altogether?
>
> jQuery is *hard*! If not for all the wonderful plugins and my
> sheer obstinacy I'd have given up in despair ages ago, as even to do
> the simplest thing you need to fully internalise the whole framework,
> and have a comprehensive in-depth understanding of Javascript and the
> DOM. 
>
> Cheers
>
> Fred
>


[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread Up-Works

Thank you James - I will try this"What if you try to use $.ajax
instead, and set the option 'async' to
'false', so that it waits for the AJAX response before the click-
through occurs? "




[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread James

That's strange. Maybe it's a race condition issue which may vary
depending on your computer. I've tried this before for logging click-
throughs and it worked fine.
What if you try to use $.ajax instead, and set the option 'async' to
'false', so that it waits for the AJAX response before the click-
through occurs?

Other than that, I'm out of ideas.

On May 29, 11:56 am, Up-Works  wrote:
> On May 29, 2:54 pm, James  wrote:
>
> > Try putting a "return false;" at the end of your click code so that it
> > doesn't go to the next page. See if the AJAX call works.
> > (Theoretically, it probably still should not if it didn't before.)
>
> > I'm not sure what you're saying about the console displaying the text
> > in red. Does it also contain any additional messages?
> > In Firebug if the line is red, it usually means that the AJAX call did
> > fire but something was wrong with the request, such as the page being
> > called was not found, or a server-side error occurred on the page.
>
> If I return false it does call the AJAX .get() but obviously does not
> load the url of the href.


[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread Up-Works



On May 29, 2:36 pm, James  wrote:
> "What" is not working?
> Clicking the link does nothing? Does 'providerid' not have a value? Is
> the AJAX not being sent? No AJAX response?


In FF and Safari it does not fetch the $.get before loading the new
page location, thus the ..lib/bannerTracking.php is not able to log
the click.  When I watch the console the > GET ../lib/
bannerTracking.php?pid=123 is RED.


[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread Up-Works



On May 29, 2:54 pm, James  wrote:
> Try putting a "return false;" at the end of your click code so that it
> doesn't go to the next page. See if the AJAX call works.
> (Theoretically, it probably still should not if it didn't before.)
>
> I'm not sure what you're saying about the console displaying the text
> in red. Does it also contain any additional messages?
> In Firebug if the line is red, it usually means that the AJAX call did
> fire but something was wrong with the request, such as the page being
> called was not found, or a server-side error occurred on the page.


If I return false it does call the AJAX .get() but obviously does not
load the url of the href.


[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread James

Try putting a "return false;" at the end of your click code so that it
doesn't go to the next page. See if the AJAX call works.
(Theoretically, it probably still should not if it didn't before.)

I'm not sure what you're saying about the console displaying the text
in red. Does it also contain any additional messages?
In Firebug if the line is red, it usually means that the AJAX call did
fire but something was wrong with the request, such as the page being
called was not found, or a server-side error occurred on the page.

On May 29, 11:44 am, Up-Works  wrote:
> On May 29, 2:36 pm, James  wrote:
>
> > "What" is not working?
> > Clicking the link does nothing? Does 'providerid' not have a value? Is
> > the AJAX not being sent? No AJAX response?
>
> In FF and Safari it does not fetch the $.get before loading the new
> page location, thus the ..lib/bannerTracking.php is not able to log
> the click.  When I watch the console the > GET ../lib/
> bannerTracking.php?pid=123 is RED.


[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread James

"What" is not working?
Clicking the link does nothing? Does 'providerid' not have a value? Is
the AJAX not being sent? No AJAX response?

On May 29, 11:23 am, Up-Works  wrote:
> Need to know why this code below records the click in IE but does not
> record the click in FF or Safari.  a.adBanner is an internal link
> within the same domain.  Thank you in advance.
>
> $('a.adBanner').live('click',function(){
>
>         var provider_id = $(this).attr('id');
>
>         var providerid = provider_id.match(/[0-9]+/g);
>
>         $.get('../lib/bannerTracking.php', {
>             pid : providerid
>             }, function() {
>
>             });
>
>     });


[jQuery] Re: Click Tracking - Works In IE Only

2009-05-29 Thread waseem sabjee
try using bind() instead of live()

On Fri, May 29, 2009 at 11:23 PM, Up-Works  wrote:

>
> Need to know why this code below records the click in IE but does not
> record the click in FF or Safari.  a.adBanner is an internal link
> within the same domain.  Thank you in advance.
>
> $('a.adBanner').live('click',function(){
>
>var provider_id = $(this).attr('id');
>
>var providerid = provider_id.match(/[0-9]+/g);
>
>$.get('../lib/bannerTracking.php', {
>pid : providerid
>}, function() {
>
>
>});
>
>});
>


[jQuery] Re: Click event not fired when hide() called by blur()

2009-05-25 Thread cohq82

This works. Thanks

On May 24, 11:29 pm, Ricardo  wrote:
> Set a flag on mousedown on the DIV to prevent blur (mousedown fires
> first):
>
> $().ready(function(){
>  var divclick = false;
>
>  $('#aa')
>   .focus(function() {
>     $('#bb').show();
>   })
>   .blur(function() {
>     if ( divclick ) return( divclick = false );
>     $('#bb').hide();
>   });
>
>  $('#bb')
>  .click(function() {
>     alert('test');
>     $('#aa').focus();
>   })
>   .mousedown(function(){
>      divclick = true;
>   });
>
> });
>
> On May 25, 2:01 am, cohq82  wrote:
>
> > Hi all,
>
> > I am running into this specific use case and could not figure out how
> > to do this. To simplify, I have a textarea and a DIV as code below.
> > The way it supposes to work is when I focus on the textarea by
> > clicking it, the DIV will show. Otherwise, it will be hidden. Then
> > when I click the DIV, there will be an alert(). However, right now if
> > I click on the DIV, it will trigger the blur() event first which calls
> > to hide() the DIV. After that, the click event is not called at all. I
> > need to be able to click on the DIV and the DIV is not hide() at all
> > and show alert(). Any help? Thanks
>
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> > http://www.w3.org/1999/xhtml";>
> > 
> > 
> > Untitled Document
> > http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
> > jquery.js" type="text/javascript">
> > 
>
> > $(document).ready(function() {
>
> > $('#aa').focus(function() {
> > $('#bb').show();
>
> > });
>
> > $('#aa').blur(function() {
> > $('#bb').hide();
>
> > });
>
> > $('#bb').click(function() {
> > alert('test');
>
> > });
> > });
>
> > 
>
> > 
>
> > 
> > This will always show
> > Hidden by defaul and alert 'test'
> > when clicked
>
> > 
> > 


[jQuery] Re: Click event not fired when hide() called by blur()

2009-05-25 Thread Ricardo

Set a flag on mousedown on the DIV to prevent blur (mousedown fires
first):

$().ready(function(){
 var divclick = false;

 $('#aa')
  .focus(function() {
$('#bb').show();
  })
  .blur(function() {
if ( divclick ) return( divclick = false );
$('#bb').hide();
  });

 $('#bb')
 .click(function() {
alert('test');
$('#aa').focus();
  })
  .mousedown(function(){
 divclick = true;
  });
});

On May 25, 2:01 am, cohq82  wrote:
> Hi all,
>
> I am running into this specific use case and could not figure out how
> to do this. To simplify, I have a textarea and a DIV as code below.
> The way it supposes to work is when I focus on the textarea by
> clicking it, the DIV will show. Otherwise, it will be hidden. Then
> when I click the DIV, there will be an alert(). However, right now if
> I click on the DIV, it will trigger the blur() event first which calls
> to hide() the DIV. After that, the click event is not called at all. I
> need to be able to click on the DIV and the DIV is not hide() at all
> and show alert(). Any help? Thanks
>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> 
> Untitled Document
> http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
> jquery.js" type="text/javascript">
> 
>
> $(document).ready(function() {
>
> $('#aa').focus(function() {
> $('#bb').show();
>
> });
>
> $('#aa').blur(function() {
> $('#bb').hide();
>
> });
>
> $('#bb').click(function() {
> alert('test');
>
> });
> });
>
> 
>
> 
>
> 
> This will always show
> Hidden by defaul and alert 'test'
> when clicked
>
> 
> 


[jQuery] Re: .click function won't work twice? addClass and hasClass little problem

2009-05-19 Thread James

I think you want this:

if($("#content").hasClass("blue")) {
$("#content").removeClass("blue");
$("#content").addClass("red");
}
if($("#content").hasClass("red")) {
$("#content").removeClass("red");
$("#content").addClass("blue");
}
if($("#content").hasClass("green")) {
$("#content").removeClass("green");
$("#content").addClass("red");
}

On May 19, 4:44 am, Edwinistrator  wrote:
> I want to change the color on every click of the div, by changing the
> class and checking if hasClass. First removeClass, then addClass.
> But this won't work?
>
> Live demo:http://www.edwinistrator.com/stuff/jquery/
>
>  "http://www.w3.org/TR/html4/loose.dtd";>
> http://www.w3.org/1999/xhtml"; lang="en">
> 
> 
> Test
>         
>         div { cursor: pointer; float: left; border: solid 1px #ccc; padding:
> 5px; }
>         .red {color: red;}
>         .blue {color: blue;}
>         .green {color: green;}
>         
>         http://ajax.googleapis.com/ajax/
> libs/jquery/1.3/jquery.min.js">
>         
>         $(document).ready(function(){
>                 $("#content").removeClass("test");
>                 $("#content").addClass("red");
>                 $("#content").click(function(){
>                         //alert("boe");
>                         if($("#content").hasClass("blue"))
>                                 $("#content").removeClass("blue");
>                                 $("#content").addClass("red");
>                         if($("#content").hasClass("red"))
>                                 $("#content").removeClass("red");
>                                 $("#content").addClass("blue");
>                         if($("#content").hasClass("green"))
>                                 $("#content").removeClass("green");
>                                 $("#content").addClass("red");
>                 });
>         });
>         
> 
> 
>         
>         I'm crazy.
>         
> 
> 


[jQuery] Re: Click-Event in Options/defaults

2009-05-15 Thread Geuintoo

This works, but is there no better way?

$.each(opts.button, function(i, n){
var func = n.click;
delete(n.click);
var button = $('')
.attr(n)
.click(func);

  $("#rtfButtons").append(button);
});


[jQuery] Re: Click-Event in Options/defaults

2009-05-15 Thread Geuintoo

"Keep in mind this recursively calls attr( key, value ) or attr ( key,
fn ), so if one of the properties you are passing is a function, the
function will be evaluated and not stored as the attribute itself."

Question:
The function should NOT will be evaluated...
Any idea?


Thanks!


[jQuery] Re: click() only binds to first match

2009-04-01 Thread MorningZ

Well, IDs are supposed to be *unique* on the page, which you do not
have

your selector would be better off like

$("span.box").click()



On Apr 1, 5:16 am, thalis  wrote:
> Hi all,
>
> I have 3 images. I want one of them to be displayed, and when user
> clicks either on  1 or 2 to swap the
> displayed image with the clicked one.
>
> Here is my (semi-functional) shot at it:
> $(document).ready( function() {
>             $('#altImg').click( function(){
>                 var mainImgSrc=$('img#mainImg').attr('src');
>                 $('img#mainImg').attr('src',$(this).attr('src'));
>                 $(this).attr('src',mainImgSrc);
>                 return false;
>             });
>
> });
>
> 
> ...
> 1
> 2
>
> It works only for the first span (i.e. successful back & forth
> swapping of displayed and  image). The second  is immune
> to clicking. Any reason why my click() binds only to the first and not
> all occurrences of #altImg ?
>
> TIA,
> --thalis
>
> ps. I swaped the positions of the 's and still only binds to the
> first occurrence


[jQuery] Re: click(function() works only once per page load?

2009-03-29 Thread Mr. Zeph

Thanks

On Sun, Mar 29, 2009 at 1:25 AM, Ricardo  wrote:

> That's as simple as changing $(".ajax_homes_primary_img").click
> (function(){ to $(".ajax_homes_primary_img").live('click', function()

Thanks, tried it, and even used livequery (amazing how fast this stuff
is to pick up!), and I was still getting the same result: $.ajax
database update worked at all times, but the second $.ajax call that
retrieved the html did not. The solution for me was to use $.get (in
conjunction with livequery.

So thank you, your answer "rebind" is correct, or at least as my situation went.


[jQuery] Re: click(function() works only once per page load?

2009-03-28 Thread Ricardo

Your click handler only applies to the elements matching
".ajax_homes_primary_img" at the time the click() function is called.
When you replace it, the new element has no event listeners attached.
You can either rebind the event every time you modify it, or use the
'live' function, which uses event delegation: http://docs.jquery.com/Events/live

That's as simple as changing $(".ajax_homes_primary_img").click
(function(){ to $(".ajax_homes_primary_img").live('click', function()
{...

cheers,
- ricardo

On Mar 28, 10:32 am, "Mr.Zeph"  wrote:
> Hi,
>
> I'm brand new to jQuery, and so far I love it! I don't know ajax from
> a cumquat and yet, here I am ajaxing around merrily, even if clumsily.
> I've run into a situation where I have a grid of images, one which is
> to be the default, or the main image. When I click the radio button,
> it correctly triggers, retrieves a page, server side that does the
> database update (correctly), then deletes the current contents of a
> tbody, and sucks in a new one (pure HTML, no json, or xml, or
> whatever). By all appearances it loads correctly, but for some reason,
> selecting another radio button fails to trigger the .click() function,
> I've tested this by using a simple alert(). I've gone through the
> archives here, and I can't discern much from the docs, but maybe I'm
> missing some key concepts that would have helped me fine tune my
> search.
>
> Is there something that I might be missing? All code (yes! that's ALL
> of it! I love jQuery!) is included below and suggestions are highly
> appreciated.
>
> // User clicked the "make primary image" radio button
> $(".ajax_homes_primary_img").click(function() {
>         //$(".ajax_homes_primary_img");
>
>         // Get and keep the table the same height so that it doesn't collapse
> on reload
>         var tblHeight = $('#homes_image_grid > tbody').height();
>         $('#homes_image_grid').css('height', tblHeight);
>
>         // Retrieve the value of the primary_image radio button, and the
> property record's ID
>         var img_id =  $(this).val();
>         var prop_id = $('#property_id_field').val();
>
>         // Hide the current records (just looks cool)
>         var tblRows = $('#homes_image_grid > tbody > tr');
>         tblRows.fadeOut('slow');
>
>         // Let's update the database table with the value of the radio button
>         $.ajax({
>                 url: '/homes/admin/index.cfm?
> fuseaction=ajax_property_images_update&property_id='+ prop_id
> +'&image_id=' + img_id,
>                 cache: false,
>                 success: function(html){
>
>                         // Clear the tbody out so as to not confuse with 
> element IDs
>                         tblRows.remove();
>                 }
>         });
>
>         // Now let's fetch the new data and append it to the tbody we just
> cleared out.
>         $.ajax({
>                 url: '/homes/admin/index.cfm?
> fuseaction=ajax_property_images_get&property_id=' + prop_id,
>                 cache: false,
>                 success: function(html){
>                         $("#homes_image_grid > tbody").append(html);
>                 }
>         });
>
> });


[jQuery] Re: Click event is not captured by jQuery after the link to click is rendered by AJAX through jQuery

2009-03-23 Thread tadatoshi

Thank you, Eric.

It worked very well.

In my previous example, I modified the code like this following your
advice:

jQuery(document).ready( function($) {

jQuery( ".class-name-for-element-for-ajax" ).click( function() {
...
jQuery.get( jQuery(this).attr("href"), { some_variable:
some_value }, null, "script" );
return false;
   }

   jQuery( ".class-name-for-link-in-right-pane" ).live( "click",
function() {
jQuery.get( jQuery(this).attr("href"), null, null, "script" );
return false;
   }

});

Then when the second element is clicked, the event is captured by
jQuery.

Thank you again for your help.

Sincerely,
Tadatoshi


On Mar 23, 1:22 pm, Eric Garside  wrote:
> It's because jQuery operates on the elements which already exist.
>
> Lets say for instance:
>
> 
> 
>
> Loads this page into div#ajax-content:
>
> 
>
> When you first render the page, you're grabbing anything that exists.
> So:
> jQ1 = jQuery('.ajax-clickery'); // .length = 1
> jQ2 = jQuery('.ajax-clickery-two'); // .length = 0 -- No elements
> exist with this class!
>
> Once your ajax runs, the values of jQ1 and jQ2 are still the same. If,
> after your ajax runs, you perform the same function again:
> jQ1b = jQuery('.ajax-clickery'); // .length = 1
> jQ2b = jQuery('.ajax-clickery-two'); // .length = 1 -- The element
> created by Ajax
>
> Now, an easy way to handle what you're doing here?
>
> ===
>
> jQuery('.class-name-for-all-ajax-elements').live('click', function(){
>     var el = jQuery(this);
>     jQuery.getScript( el.attr('href') );
>
> });
>
> Using the live click event, you'll be able to apply functionality to
> elements as they're added to the dom, through whatever means. This
> requires jquery1.3+
>
> On Mar 23, 12:47 pm, tadatoshi 
> wrote:
>
> > Hi,
>
> > I wrote a jQuery code to display a link in the side bar (like the ones
> > such as "About this group" shown in the right pane of this page)
> > through AJAX.
> > Then I want the click event on the link to be taken care of by
> > jQuery.
> > But that event is not captured by jQuery.
> > How can I capture the event?
>
> > The code looks something like this (class name etc. has been changed
> > for the purpose of posting here):
>
> > jQuery(document).ready( function($) {
>
> >     jQuery( ".class-name-for-element-for-ajax" ).click( function() {
> >         ...
> >         jQuery.get( jQuery(this).attr("href"), { some_variable:
> > some_value }, null, "script" );
> >         return false;
> >    }
>
> >    jQuery( ".class-name-for-link-in-right-pane" ).click( function() {
> >         jQuery.get( jQuery(this).attr("href"), null, null, "script" );
> >         return false;
> >    }
>
> > });
>
> > The element for the first click event above exists but the the one for
> > the second doesn't exist when a page is first displayed.
> > When the first element is clicked, as a result of AJAX call, the
> > second element is displayed.
> > Then when the second element is clicked, the second click event above
> > is not captured by jQuery above.
>
> > Thank you in advance.
>
> > Tadatoshi


[jQuery] Re: Click event is not captured by jQuery after the link to click is rendered by AJAX through jQuery

2009-03-23 Thread Eric Garside

It's because jQuery operates on the elements which already exist.

Lets say for instance:




Loads this page into div#ajax-content:



When you first render the page, you're grabbing anything that exists.
So:
jQ1 = jQuery('.ajax-clickery'); // .length = 1
jQ2 = jQuery('.ajax-clickery-two'); // .length = 0 -- No elements
exist with this class!

Once your ajax runs, the values of jQ1 and jQ2 are still the same. If,
after your ajax runs, you perform the same function again:
jQ1b = jQuery('.ajax-clickery'); // .length = 1
jQ2b = jQuery('.ajax-clickery-two'); // .length = 1 -- The element
created by Ajax

Now, an easy way to handle what you're doing here?

===

jQuery('.class-name-for-all-ajax-elements').live('click', function(){
var el = jQuery(this);
jQuery.getScript( el.attr('href') );
});

Using the live click event, you'll be able to apply functionality to
elements as they're added to the dom, through whatever means. This
requires jquery1.3+



On Mar 23, 12:47 pm, tadatoshi 
wrote:
> Hi,
>
> I wrote a jQuery code to display a link in the side bar (like the ones
> such as "About this group" shown in the right pane of this page)
> through AJAX.
> Then I want the click event on the link to be taken care of by
> jQuery.
> But that event is not captured by jQuery.
> How can I capture the event?
>
> The code looks something like this (class name etc. has been changed
> for the purpose of posting here):
>
> jQuery(document).ready( function($) {
>
>     jQuery( ".class-name-for-element-for-ajax" ).click( function() {
>         ...
>         jQuery.get( jQuery(this).attr("href"), { some_variable:
> some_value }, null, "script" );
>         return false;
>    }
>
>    jQuery( ".class-name-for-link-in-right-pane" ).click( function() {
>         jQuery.get( jQuery(this).attr("href"), null, null, "script" );
>         return false;
>    }
>
> });
>
> The element for the first click event above exists but the the one for
> the second doesn't exist when a page is first displayed.
> When the first element is clicked, as a result of AJAX call, the
> second element is displayed.
> Then when the second element is clicked, the second click event above
> is not captured by jQuery above.
>
> Thank you in advance.
>
> Tadatoshi


[jQuery] Re: click here to earn money through online

2009-03-16 Thread Happy Hyderabad
 


[jQuery] Re: Click function dosen't work, after append new html data.

2009-03-11 Thread sure

Hi errant,
  Thank you very much for quick reply. Now it works good using
live method. Your solution saves my lot of time.

with Regards
sure.

On Mar 11, 1:32 pm, errant  wrote:
> That's because events are binded to existing elements.
>
> If you're using 1.3.x, take a look at "live" 
> method:http://docs.jquery.com/Events/live#typefn. With previous versions,
> livequery plugin may be helpful:http://docs.jquery.com/Plugins/livequery
>
> On 11 мар, 09:25, sure  wrote:
>
> > Hi all,
> >           I am new to jquery. My close  click event function dosen't
> > work, when ever i append new html data to my div. Intially it is
> > working fine with static data. Please help me to fix this problem.
>
> > $(function()
> > {
> > $("#addrow").click(function()
> >                 {
> >                         alert($("#mainlayout .row").length);
> >                         var len = parseInt($("#mainlayout .row").length);
> >                         var html =" > class=\"ulpanel
> > \"> > div>1 > delete.png\" />2 > src=\"images/delete.png\" />3";
> >                         $("#mainlayout").append(html);
> >                         //$(".ulpanel li").draggable();
> >                 });
>
> > $(".close").click(function()
> >                 {
> >                         
> > //alert($(this).parent().parent().parent().attr("class"));
> >                         //alert(parseInt($(".ulpanel li").length));
> >                         if($(".ulpanel li").length==1)
> >                            $(this).parent().parent().parent().remove();
> >                         else
> >                                 $(this).parent().remove();
> >                 });
>
> > });
>
> > with Regards
> > sure
>
>


[jQuery] Re: Click function dosen't work, after append new html data.

2009-03-11 Thread errant

That's because events are binded to existing elements.

If you're using 1.3.x, take a look at "live" method:
http://docs.jquery.com/Events/live#typefn. With previous versions,
livequery plugin may be helpful: http://docs.jquery.com/Plugins/livequery

On 11 мар, 09:25, sure  wrote:
> Hi all,
>           I am new to jquery. My close  click event function dosen't
> work, when ever i append new html data to my div. Intially it is
> working fine with static data. Please help me to fix this problem.
>
> $(function()
> {
> $("#addrow").click(function()
>                 {
>                         alert($("#mainlayout .row").length);
>                         var len = parseInt($("#mainlayout .row").length);
>                         var html =" class=\"ulpanel
> \"> div>1 delete.png\" />2 src=\"images/delete.png\" />3";
>                         $("#mainlayout").append(html);
>                         //$(".ulpanel li").draggable();
>                 });
>
> $(".close").click(function()
>                 {
>                         
> //alert($(this).parent().parent().parent().attr("class"));
>                         //alert(parseInt($(".ulpanel li").length));
>                         if($(".ulpanel li").length==1)
>                            $(this).parent().parent().parent().remove();
>                         else
>                                 $(this).parent().remove();
>                 });
>
> });
>
> with Regards
> sure


[jQuery] Re: click event and window.location problem in safari

2009-02-27 Thread Karl Rudd

Try this plugin:

http://newism.com.au/blog/post/58/bigtarget-js-increasing-the-size-of-clickable-targets/

Karl Rudd

On Sat, Feb 28, 2009 at 1:49 AM, introvert  wrote:
>
> Hello
>
> I have a simple jquery code that will put a link (on click event) on a
> division. The link is read from the anchor inside of the div:
>
> $(document).ready(function() {
>   $("div.picture").click(function () {
>        var url = $(this).find("a").attr('href');
>        window.location = url;
>   });
> });
>
> This code will work fine in Firefox and IE, but in Safari it will
> return user to the url:
> http://someurl.com/http://someurl.com
>
> instead of:
> http://someurl.com
>
> How to fix this?
> Any ideas?
>
> Thanks a lot for help!


[jQuery] Re: click event and window.location problem in safari

2009-02-27 Thread brian

I don't know what the problem is or how to fix it but I'm wondering
why you need this onclick event at all. If you want the link to fill
the entire div you might be able to just give the anchor display:
block.

On Fri, Feb 27, 2009 at 9:49 AM, introvert  wrote:
>
> Hello
>
> I have a simple jquery code that will put a link (on click event) on a
> division. The link is read from the anchor inside of the div:
>
> $(document).ready(function() {
>   $("div.picture").click(function () {
>        var url = $(this).find("a").attr('href');
>        window.location = url;
>   });
> });
>
> This code will work fine in Firefox and IE, but in Safari it will
> return user to the url:
> http://someurl.com/http://someurl.com
>
> instead of:
> http://someurl.com
>
> How to fix this?
> Any ideas?
>
> Thanks a lot for help!


[jQuery] Re: .click to start dropdown, hover out to clear (mixing the two)

2009-02-18 Thread Karl Swedberg

Hi Pete,

You don't need to use .hover() with an empty function. You can  
use .mouseleave() in jQuery 1.3.x or .bind('mouseleave') in 1.2.6.


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Feb 18, 2009, at 12:28 AM, pedalpete wrote:



Ok, actually got this working with the following code

[code]
$('form#filterList span.holdDate').click(function(){
$('span#datePickers, div.datepicker').slideDown('fast');
$('span#datePickers, div.datepicker').hover(
function(){},
function(){
$('div.datepicker').slideUp('slow');
});
},
function(){


});
[/code]




[jQuery] Re: .click to start dropdown, hover out to clear (mixing the two)

2009-02-17 Thread pedalpete

Ok, actually got this working with the following code

[code]
$('form#filterList span.holdDate').click(function(){
$('span#datePickers, div.datepicker').slideDown('fast');
$('span#datePickers, div.datepicker').hover(
function(){},
function(){
$('div.datepicker').slideUp('slow');
});
},
function(){


});
[/code]


[jQuery] Re: .click to start dropdown, hover out to clear (mixing the two)

2009-02-17 Thread pedalpete

right, so does that mean their is no way to specify only the hover out
in jquery?

On Feb 17, 6:21 pm, James  wrote:
> The syntax for hover() is hover(function, function), where the first
> function is what happens when something is onmouseover and the second
> is onmouseout.
>
> $(elem).hover(
>      function() {
>          // do something on mouseover
>      },
>      function() {
>           // do something on mouseout
>      }
> );
>
> On Feb 17, 1:07 pm, pedalpete  wrote:
>
> > I've got a fairly simple form with a few dropdowns which I currently
> > trigger on hovers.
>
> > A use requested that instead of a hover, that the dropdowns be
> > triggered by a click event.
> > No problem, except that I need the dropdown to slideUp when the user
> > hovers out.
>
> > I've taken a look at the .hover documentation, but can't seem to
> > figure out how to specify the 'out' (though it does say that this
> > exists).
>
> > Here's the code I've got now
>
> > [code]
> > $('form#filterList span.holdDate').click(function(){
> >                 $('span#datePickers, div.datepicker').slideDown('fast');
>
> >                 },
> >                 $('span#datePickers').hover('out', function(){
> >                 $('#datePickers').slideUp('slow');
> >                 });
> >         });
> > [/code]
>
> > unfortunately, i'm getting an error when running this function. I
> > figure it is more efficient to only run the 'hover' code within
> > the .click function, but maybe that isn't right.


[jQuery] Re: .click to start dropdown, hover out to clear (mixing the two)

2009-02-17 Thread James

The syntax for hover() is hover(function, function), where the first
function is what happens when something is onmouseover and the second
is onmouseout.

$(elem).hover(
 function() {
 // do something on mouseover
 },
 function() {
  // do something on mouseout
 }
);

On Feb 17, 1:07 pm, pedalpete  wrote:
> I've got a fairly simple form with a few dropdowns which I currently
> trigger on hovers.
>
> A use requested that instead of a hover, that the dropdowns be
> triggered by a click event.
> No problem, except that I need the dropdown to slideUp when the user
> hovers out.
>
> I've taken a look at the .hover documentation, but can't seem to
> figure out how to specify the 'out' (though it does say that this
> exists).
>
> Here's the code I've got now
>
> [code]
> $('form#filterList span.holdDate').click(function(){
>                 $('span#datePickers, div.datepicker').slideDown('fast');
>
>                 },
>                 $('span#datePickers').hover('out', function(){
>                 $('#datePickers').slideUp('slow');
>                 });
>         });
> [/code]
>
> unfortunately, i'm getting an error when running this function. I
> figure it is more efficient to only run the 'hover' code within
> the .click function, but maybe that isn't right.


[jQuery] Re: click events on links

2009-02-14 Thread Rick Faircloth

add return false; to your code...

$('#pause').click(function() {
 do something;
 return false;
});

See if that helps...

Rick

> -Original Message-
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
> Behalf Of pedalpete
> Sent: Saturday, February 14, 2009 9:39 PM
> To: jQuery (English)
> Subject: [jQuery] Re: click events on links
> 
> 
> i've done this before just leaving out the href in the a tag. if you
> aren't going to use it, you may as well not put it in.
> 
> On Feb 14, 5:48 pm, introvert  wrote:
> > Hello.
> >
> > I have a simple anchor href link on which I put on click event
> > handler:
> >
> > 
> > $("#pause").click(function () {
> >     //do something
> >
> > });
> >
> > When I click the link the action will be preformed and the browser
> > would scroll to the top of the page (because of # in the href
> > attribute). How do I prevent that?
> >
> > Thanks for help!



[jQuery] Re: click events on links

2009-02-14 Thread pedalpete

i've done this before just leaving out the href in the a tag. if you
aren't going to use it, you may as well not put it in.

On Feb 14, 5:48 pm, introvert  wrote:
> Hello.
>
> I have a simple anchor href link on which I put on click event
> handler:
>
> 
> $("#pause").click(function () {
>     //do something
>
> });
>
> When I click the link the action will be preformed and the browser
> would scroll to the top of the page (because of # in the href
> attribute). How do I prevent that?
>
> Thanks for help!


[jQuery] Re: click/change events not recognized for checkboxes

2009-02-05 Thread James

Try:

$("#mfglist input:checkbox")
or maybe:
$("#mfglist :checkbox")
(note the space before :) might work.


Using:
$('#manufacturers:checkbox')
is saying that you have a checkbox with the ID of manufacturers, which
is incorrect.

On Feb 5, 11:09 am, sdeo  wrote:
> Hi
>   I have the following html where I have a bunch of checkboxes which I
> want to trigger events when checked/unchecked. But apparently the
> events are not being recognized.
>
> I have tried using various ways to access the checkboxes, but nothing
> seems to work.
>   1)    $('#manufacturers:checkbox').click(function(){
>   2)    $("#mfglist:checkbox").click(function(){
>
> Being new to JQuery, I did try reading all the blogs/tutorials, but no
> luck so far. Any help is really appreciated.
>
> Thanks!
> sdeo
>
> BEGIN HTML SNIPPET
>
> 
>      Manufacturers
>       
>            
>                 
>                    type="checkbox">Apple (10)
>                    type="checkbox">Nokia (30)
>                   Motorola (8)
>                   Samsung (5)
>               
>            
>       
> 
>
> JS file:
>
> function selectMfgEvent(){
>    console.log("begin selectMfgEvent");
>    $('input[type="checkbox"]').click(function(){
>                 if($(this).is(":checked")){
>                         console.log("checked = "+this);
>                 }
>
>    });
>
> $(document).load(selectMfgEvent());
>
> };
>
>


[jQuery] Re: CLick event for Select Box not supported by IE

2009-02-05 Thread James

I see. Yeah, select elements doesn't work like that.
Though I found that "click" can work that way if you give the select
element with a size attribute:

So if you re-click a selected element, it'll fire.

Does this option fit with your design?

On Feb 4, 6:01 pm, Pedram  wrote:
> Thanks , great , But consider the I want the user to Click in a Option
> which is selected right now and An event Fire Ups so Click dosen't
> work for IE and CHange doen't support it
>
> On Feb 4, 10:52 am, James  wrote:
>
> > Change should work.
>
> > $("select.actions").change(function(){
> >      if ( $(this).val() == 'NEW' ) alert('NEW was selected');
> >      else alert('NEW was not selected');
>
> > });
>
> > On Feb 4, 6:56 am, Pedram  wrote:
>
> > > Dear folk ,
> > >  I have a select box with Multiple Options
> > > Such as below
> > > 
> > >   New/Edit
> > >   1
> > >   2
> > >   3
> > > 
>
> > > I wanted to bind a Click event to the select box , so when ever we
> > > Click on the Option with the NEW value
> > > alert box appears this is my code
>
> > > $("select.actions option[value=NEW]").click(function(){
> > >   alert("worked");
>
> > > });
>
> > > this works in Firefox no problem I have problem in IE it doesn't work
> > > without any error it seems .CLICK is not supported by IE for
> > > Selectboxes , I also checked the .Change Worked
>
> > > $("select.actions").change(function(){
> > >   if($(this).find("option[value=NEW]")
> > >     alert("worked");
>
> > > });
>
> > > But does anyone have an Idea or solution for me
> > > Thanks
>
>


[jQuery] Re: CLick event for Select Box not supported by IE

2009-02-04 Thread Pedram

Thanks , great , But consider the I want the user to Click in a Option
which is selected right now and An event Fire Ups so Click dosen't
work for IE and CHange doen't support it


On Feb 4, 10:52 am, James  wrote:
> Change should work.
>
> $("select.actions").change(function(){
>      if ( $(this).val() == 'NEW' ) alert('NEW was selected');
>      else alert('NEW was not selected');
>
> });
>
> On Feb 4, 6:56 am, Pedram  wrote:
>
> > Dear folk ,
> >  I have a select box with Multiple Options
> > Such as below
> > 
> >   New/Edit
> >   1
> >   2
> >   3
> > 
>
> > I wanted to bind a Click event to the select box , so when ever we
> > Click on the Option with the NEW value
> > alert box appears this is my code
>
> > $("select.actions option[value=NEW]").click(function(){
> >   alert("worked");
>
> > });
>
> > this works in Firefox no problem I have problem in IE it doesn't work
> > without any error it seems .CLICK is not supported by IE for
> > Selectboxes , I also checked the .Change Worked
>
> > $("select.actions").change(function(){
> >   if($(this).find("option[value=NEW]")
> >     alert("worked");
>
> > });
>
> > But does anyone have an Idea or solution for me
> > Thanks


[jQuery] Re: CLick event for Select Box not supported by IE

2009-02-04 Thread James

I've never had any issues with it on any common browsers, including
IE6.

On Feb 4, 4:05 pm, Pedram  wrote:
> Ow Great so $(this).val() returns the Option value , is this
> acceptable by IE because , I think I had a Problem with that before .
>
> On Feb 4, 10:52 am, James  wrote:
>
> > Change should work.
>
> > $("select.actions").change(function(){
> >      if ( $(this).val() == 'NEW' ) alert('NEW was selected');
> >      else alert('NEW was not selected');
>
> > });
>
> > On Feb 4, 6:56 am, Pedram  wrote:
>
> > > Dear folk ,
> > >  I have a select box with Multiple Options
> > > Such as below
> > > 
> > >   New/Edit
> > >   1
> > >   2
> > >   3
> > > 
>
> > > I wanted to bind a Click event to the select box , so when ever we
> > > Click on the Option with the NEW value
> > > alert box appears this is my code
>
> > > $("select.actions option[value=NEW]").click(function(){
> > >   alert("worked");
>
> > > });
>
> > > this works in Firefox no problem I have problem in IE it doesn't work
> > > without any error it seems .CLICK is not supported by IE for
> > > Selectboxes , I also checked the .Change Worked
>
> > > $("select.actions").change(function(){
> > >   if($(this).find("option[value=NEW]")
> > >     alert("worked");
>
> > > });
>
> > > But does anyone have an Idea or solution for me
> > > Thanks
>
>


[jQuery] Re: CLick event for Select Box not supported by IE

2009-02-04 Thread Pedram

Ow Great so $(this).val() returns the Option value , is this
acceptable by IE because , I think I had a Problem with that before .

On Feb 4, 10:52 am, James  wrote:
> Change should work.
>
> $("select.actions").change(function(){
>      if ( $(this).val() == 'NEW' ) alert('NEW was selected');
>      else alert('NEW was not selected');
>
> });
>
> On Feb 4, 6:56 am, Pedram  wrote:
>
> > Dear folk ,
> >  I have a select box with Multiple Options
> > Such as below
> > 
> >   New/Edit
> >   1
> >   2
> >   3
> > 
>
> > I wanted to bind a Click event to the select box , so when ever we
> > Click on the Option with the NEW value
> > alert box appears this is my code
>
> > $("select.actions option[value=NEW]").click(function(){
> >   alert("worked");
>
> > });
>
> > this works in Firefox no problem I have problem in IE it doesn't work
> > without any error it seems .CLICK is not supported by IE for
> > Selectboxes , I also checked the .Change Worked
>
> > $("select.actions").change(function(){
> >   if($(this).find("option[value=NEW]")
> >     alert("worked");
>
> > });
>
> > But does anyone have an Idea or solution for me
> > Thanks


[jQuery] Re: CLick event for Select Box not supported by IE

2009-02-04 Thread James

Change should work.

$("select.actions").change(function(){
 if ( $(this).val() == 'NEW' ) alert('NEW was selected');
 else alert('NEW was not selected');
});

On Feb 4, 6:56 am, Pedram  wrote:
> Dear folk ,
>  I have a select box with Multiple Options
> Such as below
> 
>   New/Edit
>   1
>   2
>   3
> 
>
> I wanted to bind a Click event to the select box , so when ever we
> Click on the Option with the NEW value
> alert box appears this is my code
>
> $("select.actions option[value=NEW]").click(function(){
>   alert("worked");
>
> });
>
> this works in Firefox no problem I have problem in IE it doesn't work
> without any error it seems .CLICK is not supported by IE for
> Selectboxes , I also checked the .Change Worked
>
> $("select.actions").change(function(){
>   if($(this).find("option[value=NEW]")
>     alert("worked");
>
> });
>
> But does anyone have an Idea or solution for me
> Thanks


[jQuery] Re: Click Links in the Nnavigation Bar

2009-02-04 Thread Karl Swedberg

On Feb 4, 2009, at 1:09 AM, Pedram wrote:


Thanks  Karl , It helped me alot


Not a problem. Glad to help.


Since it's not possible in a valid DOM to have an A that is a
descendant of a UL but not a descendant of an LI, the LI is
superfluous. No need to do an extra getElementsByTagName there.


On second thought, I'm not sure that there would actually be an extra  
getElementsByTagName as of jQuery 1.3, since Sizzle (1.3's selector  
engine) starts on the right side of the selector and then walks up the  
DOM tree, checking for matches on each selector to the left in turn.  
It might still matter, but it probably matters less. Please don't take  
these musings as fact, though. I have not run any comparative  
benchmarks. You would have to do that to know for sure which is faster.


If someone else has benchmarks on these things, I'd be interested to  
see them. Also, I haven't taken a close look at Sizzle, so my  
understanding of it could be off. Please, anyone, feel free to correct  
me.


Cheers,

--Karl

Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: click event

2009-02-04 Thread jQuery Lover

You can take advantage of event delegation by binding click event to
the table tag and checking with "if" statement if the clicked cell is
not the one that has a checkbox.

For event delegation see:
http://www.learningjquery.com/2008/03/working-with-events-part-1

For row checking and stuff see:
http://www.askthecssguy.com/2008/10/josh_asks_the_css_guy_about_ro.html

For other jQuery howto's see: http://jquery-howto.blogspot.com



On Wed, Feb 4, 2009 at 3:28 PM, jq noob  wrote:
>
> I want to do a onclick event for anywhere in a table row except for a
> specific cell. In that cell I want to be able to click a checkbox. I
> have any # of rows and 12 columns in the table. I usually use a
> something like this
>
>  onmouseover="this.style.backgroundColor='white';
> this.style.cursor='pointer';"
> onmouseout="this.style.backgroundColor='<%=strColor%>';
> this.style.cursor='default';"
> style="background-color:<%=strColor%>;">
>
> In this instance I also need to allow the user to check on a bunch of
> rows and submit to another page  with the records selected. I also
> would like to still keep the row click because this is used everywhere
> else.
>
> I presume that someone could tell me how to handle this easily with
> JQuery
>
> Thanks in advance.


[jQuery] Re: Click Links in the Nnavigation Bar

2009-02-03 Thread Pedram

Thanks  Karl , It helped me alot

On Feb 1, 9:47 am, Karl Swedberg  wrote:
> On Feb 1, 2009, at 3:06 AM, Pedram wrote:
>
>
>
> > I have another  tiny question
> >  $("Ul li a"), $("ul a"), $("a",$("ul"))
> > which one has the great performance !!?
>
> I would go with either $('ul a') or $('a', 'ul'), but $('ul a') seems  
> more readable to me, as it follows the CSS syntax.
>
> Since it's not possible in a valid DOM to have an A that is a  
> descendant of a UL but not a descendant of an LI, the LI is  
> superfluous. No need to do an extra getElementsByTagName there.
>
> Also, if you're using a contextual selector, you don't need to wrap  
> the context in its own jQuery object -- $("a",$("ul")).
>
> --Karl
>
> > On Feb 1, 12:02 am, Pedram  wrote:
> >> I just had some Doubt , the performance is great
>
> >> On Jan 31, 11:54 am, Karl Swedberg  wrote:
>
> >>> Hi Pedram,
>
> >>> I agree with Nic. Especially if you're only dealing with 4 elements,
> >>> binding directly on them seems like the most sensible solution.
>
> >>> Are you noticing performance problems? You shouldn't be seeing any,
> >>> with scripts this basic. In any case, there are a couple selector
> >>> optimizations you could implement, if necessary. Something like  
> >>> this:
>
> >>> var $navBarLinks = $('#your-nav-bar-id a');
>
> >>> $navBarLinks.click(function() {
> >>>    $navBarLinks.removeClass('active');
> >>>    $(this).addClass('active');
>
> >>> });
>
> >>> --Karl
>
> >>> 
> >>> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> >>> On Jan 31, 2009, at 2:36 PM, Pedram wrote:
>
>  I'm looking to improve the performance ,  which of these 2 codes  
>  has
>  the best performance.
>
>  On Jan 30, 1:04 am, Nic Luciano  wrote:
> > What exactly are you trying to do, what is the issue? Maybe just
> > preference
> > here (and I'm also just guessing what you're asking) but I don't
> > see a
> > reason not to put the events on the elements themselves
>
> > $("ul li a").click(function() {
> >         $
> > (this).parent().parent().find(".active").removeClass("active");
> >         $(this).addClass("active");
> >     });
>
> > On Fri, Jan 30, 2009 at 3:07 AM, Pedram   
> > wrote:
>
> >> Dear Karl ,
> >> I know You are Expert in these Issues do you have any idea for me
> >> Thanks
>
> >> On Jan 29, 5:44 pm, Pedram  wrote:
> >>> Hi Folks ,
> >>>   I have some links in my Navigation bar such as below , I Used
> >>> FIND
> >>> in my code , does anyone has any better solution for me ,
> >>>   I also used Event Delegation in the system .
>
> >>> 
> >>>   b
> >>>   c
> >>>   d
> >>> 
>
> >>>   $("ul").bind("click",function(e){
> >>>       var clicked=$(e.target);
> >>>       $(this).find("a.active").removeClass("active");
> >>>       clicked.addClass("active");
> >>>   });


[jQuery] Re: click Event not working on first binded element on IE after one click

2009-02-02 Thread shahku...@gmail.com

Using that doesn't work either. The first word, stops registering the
click event after one click. The only way I found to resolve the issue
is, add the following code to the page:
Hidden

In this case, Hidden becomes the "first word", so the rest of the page
works with the click event.

Thanks

On Feb 1, 5:33 pm, Ricardo Tomasi  wrote:
> It probably won't make any difference, but why not use the 'click'
> event and 'this'? There is no need to get e.target if there are no
> child elements. Also, if you're doing a POST, why are you using a
> querystring?
>
> $('.hint').click(function(){
>      var clickText = $(this).text();
>      $.post('term.cfc', {method: 'getTermDef', returnFormat: 'json',
> term:clickText}, showHint, "json");
>
> });
>
> Have you tried a simple alert/log function in place of showHint, as a
> check for the event firing?
>
> On Feb 1, 5:33 pm, "shahku...@gmail.com"  wrote:
>
>
>
> > So, I am implementing a page on which words that have hints associated
> > in the DB are binded with the click event to show the Hint. Initially,
> > I go through and replace the words with html that goes  > class="hint">word
>
> > So, then I bind the hint class with the click event,
> > $(".hint").bind("mouseup",function(e)
> > {
> >         var clickElement = e.target;
> >         var clickText = $(clickElement).text();
> >         $.post('term.cfc?method=getTermDef&returnFormat=json',
> > {term:clickText},showHint,"json");}
>
> > )
>
> > The problem is on IE 7, the first word that is binded, works fine for
> > the first click, but after that the click event for it is not
> > registered. For the rest of the words, the click event works fine.
>
> > On FF, everything works fine.
>
> > Any ideas on what could be wrong here?- Hide quoted text -
>
> - Show quoted text -


[jQuery] Re: click Event not working on first binded element on IE after one click

2009-02-01 Thread Ricardo Tomasi

It probably won't make any difference, but why not use the 'click'
event and 'this'? There is no need to get e.target if there are no
child elements. Also, if you're doing a POST, why are you using a
querystring?

$('.hint').click(function(){
 var clickText = $(this).text();
 $.post('term.cfc', {method: 'getTermDef', returnFormat: 'json',
term:clickText}, showHint, "json");
});

Have you tried a simple alert/log function in place of showHint, as a
check for the event firing?

On Feb 1, 5:33 pm, "shahku...@gmail.com"  wrote:
> So, I am implementing a page on which words that have hints associated
> in the DB are binded with the click event to show the Hint. Initially,
> I go through and replace the words with html that goes  class="hint">word
>
> So, then I bind the hint class with the click event,
> $(".hint").bind("mouseup",function(e)
> {
>         var clickElement = e.target;
>         var clickText = $(clickElement).text();
>         $.post('term.cfc?method=getTermDef&returnFormat=json',
> {term:clickText},showHint,"json");}
>
> )
>
> The problem is on IE 7, the first word that is binded, works fine for
> the first click, but after that the click event for it is not
> registered. For the rest of the words, the click event works fine.
>
> On FF, everything works fine.
>
> Any ideas on what could be wrong here?


  1   2   3   >