Closed (won't fix)
Project:
Modal Frame API
Version:
6.x-1.x-dev
Component:
Javascript
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2010 at 19:57 UTC
Updated:
16 Apr 2010 at 18:31 UTC
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
Comment #1
markus_petrux commentedRe: "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?
Comment #2
Gabriel R. commentedHi 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.
Comment #3
markus_petrux commentedOh, 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.
Comment #4
Gabriel R. commentedComment #5
markus_petrux commentedI'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.