Problem with onComplete of element.load().

47 views
Skip to first unread message

molipha

unread,
Oct 7, 2012, 12:44:27 PM10/7/12
to mootool...@googlegroups.com
function (page, dest)
               $$(dest).set('load',
                    {
                        url: page,
                        method: 'get' ,
                        onComplete: function(){
                            linkadjuster.A(dest + " ");  //linkadjuster adds click events to the loaded page's <a> tags        
                        }
                    }
                ).load();
            },

This function is called...
   - when the page is first loaded, it loads initial content into div id="a"
   - when a link is clicked, it loads the href into div id="b"

When the page first loads, no problem.
When the first link is clicked, no problem.
When the second link is clicked (or the same link clicked again), onComplete fires twice
When the nth link is clicked, onComplete fires n times.

So somehow each successive event is being added to a chain of prior events and they all fire.

Anyone know what is going on?

Matthew Hazlett

unread,
Oct 7, 2012, 2:50:00 PM10/7/12
to mootool...@googlegroups.com
Really need to see it in a fiddle with more of your code.

Are you only calling this function one time or are you calling it
multiple times thus adding multiple onCompletes

Sanford Whiteman

unread,
Oct 7, 2012, 10:57:38 PM10/7/12
to molipha
Can you put this in a runnable, editable jsFiddle?

-- Sandy

gonchuki

unread,
Oct 8, 2012, 10:00:55 AM10/8/12
to mootool...@googlegroups.com
Your problem seems to be that using set('load',...) with an event multiple times actually adds that event those many times.
When you do a set call you are not replacing the existing event, just piling one onComplete on top of the other.
Reply all
Reply to author
Forward
0 new messages