Hi,

You should read about JavaScript event delegation. This is what they
recommend.

Wicket has basic support for this
with org.apache.wicket.ajax.attributes.AjaxRequestAttributes#setChildSelector.
I.e. you can register an Ajax behavior on the table or tbody and use
childSelector to "listen" for events only on specific children, e.g. 'tr',
'td', 'td div', etc.

This is more lightweight than using Wicket's built-in AjaxLink, but it is
also a bit more complex for you as an application developer.

Good luck!


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Oct 27, 2014 at 8:37 PM, Jason Novotny <jason.novo...@gmail.com>
wrote:

>
> Hi Martin,
>
> Thanks for the help-- I've reached out to them, the js appears pretty
> complex
> http://cdn.datatables.net/1.10.3/js/jquery.dataTables.js
>
>
> They indicate that listeners need to be added according to:
> http://www.datatables.net/examples/advanced_init/events_live.html
>
> Is there any kind of "mode" in wicket possibly that would preserve the
> listeners in this way?
>
> Thanks, Jason
>
>
> On 10/26/14, 11:40 PM, Martin Grigorov wrote:
>
>> Hi,
>>
>> Try with Ajax loading of the new pages.
>>
>> I am not sure how DataTables removes and re-adds the rows later. It should
>> use jQuery's clone(true, true) to preserve the event bindings. Ask in
>> their
>> forums.
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Sun, Oct 26, 2014 at 12:46 AM, Jason Novotny <jason.novo...@gmail.com>
>> wrote:
>>
>>  I've managed to figure out the cause of the problem but no solution.
>>>
>>> jquery datatables removes DOM elements when configured for pagination.
>>> This means the AjaxLinks in my listview generate wicket javascript like:
>>>
>>> Wicket.Ajax.ajax({"u":"./executed?7-1.IBehaviorListener.0-container-
>>> executedTransactionPanel-executedListView-0-
>>> detailsLink","e":"click","c":"
>>> detailsLinkff"});;
>>> Wicket.Ajax.ajax({"u":"./executed?7-1.IBehaviorListener.0-container-
>>> executedTransactionPanel-executedListView-1-
>>> detailsLink","e":"click","c":"
>>> detailsLink100"});;
>>> Wicket.Ajax.ajax({"u":"./executed?7-1.IBehaviorListener.0-container-
>>> executedTransactionPanel-executedListView-2-
>>> detailsLink","e":"click","c":"
>>> detailsLink101"});;
>>> Wicket.Ajax.ajax({"u":"./executed?7-1.IBehaviorListener.0-container-
>>> executedTransactionPanel-executedListView-3-
>>> detailsLink","e":"click","c":"
>>> detailsLink102"});;
>>> ...
>>>
>>>
>>> If the table has 2 pages, it removes the DOM elements from the 2nd page
>>> so
>>> I get the wicket debug error  "Wicket.Ajax: Cannot bind a listener for
>>> event "click" on element "elementId" because the element is not in the
>>> DOM"
>>>
>>> Now when I hit the link for next page of the table, the DOM has been
>>> updated to reflect the rows, but the javascript events need to be added
>>> again and so the links are broken.
>>>
>>> Is there any good way to do this?
>>>
>>> Thanks, Jason
>>>
>>>
>>> On 10/24/14, 1:24 PM, Jason Novotny wrote:
>>>
>>>  I should add I'm using Wicket 6.17.
>>>>
>>>> Thanks, Jason
>>>>
>>>> On 10/24/14, 10:47 AM, Jason Novotny wrote:
>>>>
>>>>  Hi,
>>>>>
>>>>> I'm using latest jquery DataTable with a ListView and in wicket:head of
>>>>> the page, I initiate the DataTable:
>>>>>
>>>>> $(function () {
>>>>>              $('.datatable_executed').dataTable({
>>>>>                  'lengthChange': false,
>>>>>                  'dom': '<"top"<"doc-filter"><"holder"ip>>t',
>>>>>                  "language": {"info": "_START_-_END_ of _TOTAL_"},
>>>>>                  "aaSorting": [],
>>>>>                  'iDisplayLength': 12
>>>>>              });
>>>>>          });
>>>>>
>>>>> It all looks good, however because one of my columns contains
>>>>> AjaxLinks,
>>>>> I get an error from my wicket debug window with the following:
>>>>> "Wicket.Ajax: Cannot bind a listener for event "click" on element
>>>>> "elementId" because the element is not in the DOM"
>>>>>
>>>>> The thing is the links seem to actually work on the first page, but
>>>>> when
>>>>> I click -> to go to the next page the links don't work. Has anyone
>>>>> experienced this before or have any idea how I can debug this?
>>>>>
>>>>> Thanks, Jason
>>>>>
>>>>>
>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to