• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

live binding the load event in jQuery

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am setting up jQuery Tools overlays on anchor tags that have rel attributes in a document ready handler. I have some such anchor tags living in some dynamically loaded content, so I attempted to use .live() with the load event to do what I need.



Unfortunately, not only does this not set up an overlay on the dynamically loaded anchors, it fails to execute for anchors present in the initial page.

Please advise.

Thanks,
Rob
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anchors do not have onload events.

Eric
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh, it just occurred to me that anchor tags don't get load events, so that's why this didn't work, but is there any event I could use here?

Thanks,
Rob
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know there isn't a load event for anchors.

For what you are trying to accomplish I'd use the LiveQuery plugin and set up a match handler for the anchors.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:As far as I know there isn't a load event for anchors.

For what you are trying to accomplish I'd use the LiveQuery plugin and set up a match handler for the anchors.



Or just call the one line in your Ajax success function.

Eric
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:As far as I know there isn't a load event for anchors.

For what you are trying to accomplish I'd use the LiveQuery plugin and set up a match handler for the anchors.



Could you elaborate on this? I don't understand how LiveQuery is buying me anything I can't get from .live(). My goal here is to execute $.fn.overlay() whenever a matching element is added to the DOM.

Thanks,
Rob
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
live() only allows you to establish event handlers pro-actively. That doesn't help you in this case because there's no event when the anchor gets created.

With LiveQuery you register a match handler that triggers when the anchor comes into existence and you can do anything you want in that handler.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic