0

I have a page on which i create a dynamic div popup with a disabled background after the page loads.

document.observe('dom:loaded', function() {
Create DIV POPUP and DISPLAY IT.
});

I had to do this because in IE if i dont execute the script after the dom loads, the popup shows up but the background has no content (Nothing has loaded).

Beside this i have used an observer for page content to invoke a script for some elements for example :

document.observe('dom:loaded', function() {

$$('a').invoke('observe', 'focus', function(event) {
alert("Hi There");
});

means on focus it displays a message. , everything works perfect for elements my problem is : The invoker doesnt work for elements which are inside the dynamic div popup , i guess it doesnt recognize them since both loads after the dom.

I hope you guys can help!

MByD
  • 135,866
  • 28
  • 264
  • 277
Rad
  • 11
  • 1

1 Answers1

0

You're using MooTools, right? I'm not using it for quite some time, in favor of jQuery, so I can't remember the syntax...

But basically, you have two options:

One is to call the invoke as a callback of the function that create and displays the div.

The second one is to find a MooTool method similar to jQuery .live() method, there probably be one, default or by plugin. It binds events to all matched elements in the page, and to all that comes afterwards.

Ortiga
  • 8,455
  • 5
  • 42
  • 71
  • Sorry, bad memory... Anyway, the answer is the same, add as callback, or find a function that listen to new elements - what you need may be here: http://stackoverflow.com/questions/1479782/prototype-equivalent-for-jquery-live-function – Ortiga Apr 11 '11 at 20:27