[jQuery] Re: event question
http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F -- Ariel Flesler http://flesler.blogspot.com On 23 abr, 10:12, Brian Ronk <[EMAIL PROTECTED]> wrote: > Hmmm... That would work perfectly. I'll take a look at it. Thanks. > > On Apr 22, 4:55 pm, "Jake McGraw" <[EMAIL PROTECTED]> wrote: > > > > > The default behavior: > > > $(".classname").click(function(){ > > alert("Hello, world!"); > > > }); > > > $("body").append('Click Me!'); > > > Clicking "Click Me!" would do nothing. > > > Using the liveQuery plugin (http://brandonaaron.net/docs/livequery/): > > > $(".classname").livequery("click", function(event) { > > alert("Hello, world!"); > > > }); > > > $("body").append('Click Me!'); > > > Clicking "Click Me!" should now produce an alert window. > > > - jake > > > On Tue, Apr 22, 2008 at 4:45 PM, Brian Ronk <[EMAIL PROTECTED]> wrote: > > > > I have a click even that I add to a certain class when the page is > > > created. There is the possibility of dynamically adding another > > > element with that class, and I would like to have the same click even > > > added. I'm just wondering what would happen if I registered the click > > > event for that class, would that work? For instance: > > > > At page creation, this is run: > > > $('.classname').click(function() { > > > ... > > > }); > > > > If I ran this after a new element with that class was created, would > > > that screw anything up. I do have an id associated with the element, > > > so I could just add the event that way. I just wasn't sure if there > > > might be a better way, or if I could add that to a function, and just > > > call it when needed.- Ocultar texto de la cita - > > - Mostrar texto de la cita -
[jQuery] Re: event question
Hmmm... That would work perfectly. I'll take a look at it. Thanks. On Apr 22, 4:55 pm, "Jake McGraw" <[EMAIL PROTECTED]> wrote: > The default behavior: > > $(".classname").click(function(){ > alert("Hello, world!"); > > }); > > $("body").append('Click Me!'); > > Clicking "Click Me!" would do nothing. > > Using the liveQuery plugin (http://brandonaaron.net/docs/livequery/): > > $(".classname").livequery("click", function(event) { > alert("Hello, world!"); > > }); > > $("body").append('Click Me!'); > > Clicking "Click Me!" should now produce an alert window. > > - jake > > On Tue, Apr 22, 2008 at 4:45 PM, Brian Ronk <[EMAIL PROTECTED]> wrote: > > > I have a click even that I add to a certain class when the page is > > created. There is the possibility of dynamically adding another > > element with that class, and I would like to have the same click even > > added. I'm just wondering what would happen if I registered the click > > event for that class, would that work? For instance: > > > At page creation, this is run: > > $('.classname').click(function() { > > ... > > }); > > > If I ran this after a new element with that class was created, would > > that screw anything up. I do have an id associated with the element, > > so I could just add the event that way. I just wasn't sure if there > > might be a better way, or if I could add that to a function, and just > > call it when needed.
[jQuery] Re: event question
The default behavior: $(".classname").click(function(){ alert("Hello, world!"); }); $("body").append('Click Me!'); Clicking "Click Me!" would do nothing. Using the liveQuery plugin (http://brandonaaron.net/docs/livequery/): $(".classname").livequery("click", function(event) { alert("Hello, world!"); }); $("body").append('Click Me!'); Clicking "Click Me!" should now produce an alert window. - jake On Tue, Apr 22, 2008 at 4:45 PM, Brian Ronk <[EMAIL PROTECTED]> wrote: > > I have a click even that I add to a certain class when the page is > created. There is the possibility of dynamically adding another > element with that class, and I would like to have the same click even > added. I'm just wondering what would happen if I registered the click > event for that class, would that work? For instance: > > At page creation, this is run: > $('.classname').click(function() { > ... > }); > > If I ran this after a new element with that class was created, would > that screw anything up. I do have an id associated with the element, > so I could just add the event that way. I just wasn't sure if there > might be a better way, or if I could add that to a function, and just > call it when needed. >