On a site I work on, I have a rich mouse-over tooltip that loads a mini user profile. Inside it is a link to "Add a friend". This link needs to open the destination page in a modal panel, but it doesn't.

When links to modal panels are added to the page on the fly, they don't work as expected.

The fix is to use live() instead of bind() to assign the actions. jQuery will do the right thing.

PS: I didn't try the module yet, I checked the code.

Comments

markus_petrux’s picture

Category: bug » support
Status: Active » Fixed

Re: "added to the page on the fly"

Not really sure what you mean here.

Re: "I didn't try the module yet"

So... it seems the bug could not really exist?

Gabriel R.’s picture

Hi Markus,

The bug occurs with elements added to the page DOM dynamically, e.g. with ajax. These elements added after document.ready() don't get the bind() treatment. To include ''upcoming'' elements in the selector, use live() instead of bind(). See http://api.jquery.com/live/

I'd be surprised and very happy if the bug didn't exist.

markus_petrux’s picture

Oh, I see. However, this issue does not apply under the context of Drupal 6. Here, we should use Drupal.behaviors rather than document.ready() (see http://drupal.org/node/205296 and http://drupal.org/node/114774#javascript-behaviors ), and all code that parses Ajax requests should also invoke Drupal.attachBehaviors(context), which is invoked initially by Drupal itself.

Also please note that Drupal 6 ships with jQuery 1.2.6, where live() was not implemented yet.

Gabriel R.’s picture

Category: support » feature
Status: Fixed » Postponed
markus_petrux’s picture

Status: Postponed » Closed (won't fix)

I'm sorry, but Drupal 7 is still based on the same principle, and I think using live() is not necessary.

I won't implement live() here until this is recommended from Drupal coding standards.