You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nick Pratt <nb...@gmail.com> on 2013/03/06 16:47:20 UTC

JS execution order problem

Im having a problem with Javascript execution order that I could use some
help with.  I made a quickstart here:
https://dl.dropbox.com/u/107816727/quickstart.tar.gz

Basically, this is a Wicket DefaultDataTable, with an embedded
AjaxEventBehavior, overlaid with a Datatables.net JS behavior (
www.datatables.net).

What seems to be happening is that the Datatables.net JS is executing
before the Wicket AjaxEventBehavior JS, and in so doing, it paginates the
table and removes a couple of IDs that Wicket then cannot find.
I thought the default JS execution order was children first, then parent,
so I was expecting the AjaxEventBehavior JS to execute first and then the
Datatables.net JS (which is on the parent DefaultDataTable)

To reproduce simply click any of the "Click Me" cells in the table.

Any suggestions would be most appreciated,

Regards

Nick

Re: JS execution order problem

Posted by Nick Pratt <nb...@gmail.com>.
I logged: https://issues.apache.org/jira/browse/WICKET-5082 and added some
comments with my interpretation of what's going on.

N

On Wed, Mar 6, 2013 at 12:31 PM, Nick Pratt <nb...@gmail.com> wrote:

> I take some of that back:
>
> In the initial page rendering, the Javascript is ordered as I expect
> (child JS then parent JS).
> However, in the Ajax update, the Wicket listeners are added *after* the
> datatables init call, which results in an out of order sequence.
>
> Why is the Ajax update change the order of the JS of the parent and child
> elements?
>
> N
>
> On Wed, Mar 6, 2013 at 12:27 PM, Nick Pratt <nb...@gmail.com> wrote:
>
>> Thanks - that seems to confirm the problem - delaying the Datatables JS
>> to after the Wicket link listeners have executed will fix it, since the
>> errors are coming from the Wicket Link Listeners not being able to find
>> markup IDs that the Datatables JS paginates out of view. (load fires after
>> ready if my research is correct)
>>
>> I expect the execution order to be:
>> 1. All link listeners within the table would be executed (all rows in
>> table are available at this point)
>> 2. Datatables JS then executes and paginates the table
>>
>> Although when I look at the page source I see the Wicket event listeners
>> listed before the Datatables JS, they seem to be executing in a different
>> order - this is what is confusing.
>>
>> N
>>
>>  On Wed, Mar 6, 2013 at 12:10 PM, Andrea Del Bene <an...@gmail.com>wrote:
>>
>>> Replacing OnDomReadyHeaderItem with OnLoadHeaderItem (class
>>> DatatablesBehavior) seems to solve your problem. It's likely that your
>>> script (the one from DatatablesBehavior) depends on some other code and it
>>> must wait for it to be loaded before being executed.
>>>
>>>> Im having a problem with Javascript execution order that I could use
>>>> some
>>>> help with.  I made a quickstart here:
>>>> https://dl.dropbox.com/u/**107816727/quickstart.tar.gz<https://dl.dropbox.com/u/107816727/quickstart.tar.gz>
>>>>
>>>> Basically, this is a Wicket DefaultDataTable, with an embedded
>>>> AjaxEventBehavior, overlaid with a Datatables.net JS behavior (
>>>> www.datatables.net).
>>>>
>>>> What seems to be happening is that the Datatables.net JS is executing
>>>> before the Wicket AjaxEventBehavior JS, and in so doing, it paginates
>>>> the
>>>> table and removes a couple of IDs that Wicket then cannot find.
>>>> I thought the default JS execution order was children first, then
>>>> parent,
>>>> so I was expecting the AjaxEventBehavior JS to execute first and then
>>>> the
>>>> Datatables.net JS (which is on the parent DefaultDataTable)
>>>>
>>>> To reproduce simply click any of the "Click Me" cells in the table.
>>>>
>>>> Any suggestions would be most appreciated,
>>>>
>>>> Regards
>>>>
>>>> Nick
>>>>
>>>>
>>>
>>> ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

Re: JS execution order problem

Posted by Nick Pratt <nb...@gmail.com>.
I take some of that back:

In the initial page rendering, the Javascript is ordered as I expect (child
JS then parent JS).
However, in the Ajax update, the Wicket listeners are added *after* the
datatables init call, which results in an out of order sequence.

Why is the Ajax update change the order of the JS of the parent and child
elements?

N

On Wed, Mar 6, 2013 at 12:27 PM, Nick Pratt <nb...@gmail.com> wrote:

> Thanks - that seems to confirm the problem - delaying the Datatables JS to
> after the Wicket link listeners have executed will fix it, since the errors
> are coming from the Wicket Link Listeners not being able to find markup IDs
> that the Datatables JS paginates out of view. (load fires after ready if my
> research is correct)
>
> I expect the execution order to be:
> 1. All link listeners within the table would be executed (all rows in
> table are available at this point)
> 2. Datatables JS then executes and paginates the table
>
> Although when I look at the page source I see the Wicket event listeners
> listed before the Datatables JS, they seem to be executing in a different
> order - this is what is confusing.
>
> N
>
>  On Wed, Mar 6, 2013 at 12:10 PM, Andrea Del Bene <an...@gmail.com>wrote:
>
>> Replacing OnDomReadyHeaderItem with OnLoadHeaderItem (class
>> DatatablesBehavior) seems to solve your problem. It's likely that your
>> script (the one from DatatablesBehavior) depends on some other code and it
>> must wait for it to be loaded before being executed.
>>
>>> Im having a problem with Javascript execution order that I could use some
>>> help with.  I made a quickstart here:
>>> https://dl.dropbox.com/u/**107816727/quickstart.tar.gz<https://dl.dropbox.com/u/107816727/quickstart.tar.gz>
>>>
>>> Basically, this is a Wicket DefaultDataTable, with an embedded
>>> AjaxEventBehavior, overlaid with a Datatables.net JS behavior (
>>> www.datatables.net).
>>>
>>> What seems to be happening is that the Datatables.net JS is executing
>>> before the Wicket AjaxEventBehavior JS, and in so doing, it paginates the
>>> table and removes a couple of IDs that Wicket then cannot find.
>>> I thought the default JS execution order was children first, then parent,
>>> so I was expecting the AjaxEventBehavior JS to execute first and then the
>>> Datatables.net JS (which is on the parent DefaultDataTable)
>>>
>>> To reproduce simply click any of the "Click Me" cells in the table.
>>>
>>> Any suggestions would be most appreciated,
>>>
>>> Regards
>>>
>>> Nick
>>>
>>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: JS execution order problem

Posted by Nick Pratt <nb...@gmail.com>.
Thanks - that seems to confirm the problem - delaying the Datatables JS to
after the Wicket link listeners have executed will fix it, since the errors
are coming from the Wicket Link Listeners not being able to find markup IDs
that the Datatables JS paginates out of view. (load fires after ready if my
research is correct)

I expect the execution order to be:
1. All link listeners within the table would be executed (all rows in table
are available at this point)
2. Datatables JS then executes and paginates the table

Although when I look at the page source I see the Wicket event listeners
listed before the Datatables JS, they seem to be executing in a different
order - this is what is confusing.

N

On Wed, Mar 6, 2013 at 12:10 PM, Andrea Del Bene <an...@gmail.com>wrote:

> Replacing OnDomReadyHeaderItem with OnLoadHeaderItem (class
> DatatablesBehavior) seems to solve your problem. It's likely that your
> script (the one from DatatablesBehavior) depends on some other code and it
> must wait for it to be loaded before being executed.
>
>> Im having a problem with Javascript execution order that I could use some
>> help with.  I made a quickstart here:
>> https://dl.dropbox.com/u/**107816727/quickstart.tar.gz<https://dl.dropbox.com/u/107816727/quickstart.tar.gz>
>>
>> Basically, this is a Wicket DefaultDataTable, with an embedded
>> AjaxEventBehavior, overlaid with a Datatables.net JS behavior (
>> www.datatables.net).
>>
>> What seems to be happening is that the Datatables.net JS is executing
>> before the Wicket AjaxEventBehavior JS, and in so doing, it paginates the
>> table and removes a couple of IDs that Wicket then cannot find.
>> I thought the default JS execution order was children first, then parent,
>> so I was expecting the AjaxEventBehavior JS to execute first and then the
>> Datatables.net JS (which is on the parent DefaultDataTable)
>>
>> To reproduce simply click any of the "Click Me" cells in the table.
>>
>> Any suggestions would be most appreciated,
>>
>> Regards
>>
>> Nick
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: JS execution order problem

Posted by Andrea Del Bene <an...@gmail.com>.
Replacing OnDomReadyHeaderItem with OnLoadHeaderItem (class 
DatatablesBehavior) seems to solve your problem. It's likely that your 
script (the one from DatatablesBehavior) depends on some other code and 
it must wait for it to be loaded before being executed.
> Im having a problem with Javascript execution order that I could use some
> help with.  I made a quickstart here:
> https://dl.dropbox.com/u/107816727/quickstart.tar.gz
>
> Basically, this is a Wicket DefaultDataTable, with an embedded
> AjaxEventBehavior, overlaid with a Datatables.net JS behavior (
> www.datatables.net).
>
> What seems to be happening is that the Datatables.net JS is executing
> before the Wicket AjaxEventBehavior JS, and in so doing, it paginates the
> table and removes a couple of IDs that Wicket then cannot find.
> I thought the default JS execution order was children first, then parent,
> so I was expecting the AjaxEventBehavior JS to execute first and then the
> Datatables.net JS (which is on the parent DefaultDataTable)
>
> To reproduce simply click any of the "Click Me" cells in the table.
>
> Any suggestions would be most appreciated,
>
> Regards
>
> Nick
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org