http://ryanflorence.com/event-delegation-with-mootools-quit-selecting-all-those-elements/
There's some more info if you need it.
On Feb 17, 2010, at 7:17 AM, apathetic wrote:
Awesome, thanks so much everyone. This helps immensely.
On Feb 16, 11:02 pm, Ryan Florence <[email protected]> wrote:
1.3 should add focus and blur, not sure about change and submit.
Sent from my iPhone
On Feb 16, 2010, at 4:13 PM, Barry van Oudtshoorn
<[email protected]
> wrote:
:relay takes any valid selector. Seehttp://jsfiddle.net/T7Fmy/2/
for examples (sorry about the bright colours!)
Notice how if you don't stop the event, it bubbles up. Also notice
that the function you supply to your :relay-ed event gets the
"evented" element as its second argument.
One more thing -- events such as focus, blur, and a few others don't
work with the current MooTools event delegation system -- you'll
have to wait for Moo2 for that.
- Barry
On 17/02/10 02:08, apathetic wrote:
Thank you! That exactly what I was searching for.
Are you familiar with the argument :relay takes, per chance?
Can I do this: click:relay('.child .anotherChild a') ?
or something to that effect...? maybe like: click:relay($$
('.child .anotherChild a'))
On Feb 16, 12:32 pm, Thierry bela nanga<[email protected]> wrote:
with Event delegation, you don't have to attach events to
elements,
you'll just attach the events to the container, and it will still
work even
if you change the Dom.
http://mootools.net/docs/more/Element/Element.Delegation
On Tue, Feb 16, 2010 at 6:21 PM, apathetic<[email protected]>
wrote:
I know this may be a common question, but I've been unable to
find a
satisfactory answer and I'd like to know once and for all if it's
possible to do this:
I have a container div that is reloaded via an AJAX call.
However,
inside this div there are quite a few other divs, buttons, etc,
that I
have attached events to. When the AJAX updates the container div,
all
attached events/functions are lost. I would, of course, prefer to
keep
this functionality and not have to re-bind everything after each
successful AJAX call.
After seeing a post from Aaron Newton at
http://n2.nabble.com/Handling-the-changing-DOM-structure-with-AJAX-fo
...
,
I got the idea to create a Class and pass it the container div,
and
then let the Class maintain the state of my application. However,
this
is where I run into problems-- I'm not sure how I can maintain
the
state of my added events this way. Is there some way a Class can
remember what functions/events have been bound to the children of
the
element passed to it, so that they won't need to be re-bound upon
each
AJAX call?
Here's a stripped down example of what I'm talking about:
http://mootools.net/shell/5PgCL/6/
I've attached events to div's one, two, and three, but these are
lost
when the container is reloaded. I pass the container div to the
Class
but am currently doing nothing with it.
If anyone has any thoughts please share!
--http://tbela99.blogspot.com/
fax : (+33) 08 26 51 94 51
--
Not sent from my iPhone.