I figured out the difference:

when the if condition is met, the datatable isn't displayed.

The HTML source has the following libraries included:
<script src="/assets/0.0.1-SNAPSHOT/ctx/js/jquery-ui-1.8.19.custom.min.js"
type="text/javascript"></script>
<script src="/assets/0.0.1-SNAPSHOT/ctx/js/TableTools.js"
type="text/javascript"></script>
<script src="/assets/0.0.1-SNAPSHOT/ctx/js/dataTables.editor.min.js"
type="text/javascript"></script>
<script src="/assets/0.0.1-SNAPSHOT/ctx/js/dataTables.editor.commons.js"
type="text/javascript"></script>

When the if condition is NOT met, the datatable is displayed and ALSO the
tapestry libraries for datatables are included:

<script
src="/assets/0.0.1-SNAPSHOT/jquery/assets/components/datatables/jquery.dataTables.js"
type="text/javascript"></script>
<script
src="/assets/0.0.1-SNAPSHOT/jquery/assets/components/datatables/dataTables.js"
type="text/javascript"></script>

These 2 libraries are not included when the if condition is met and that's
why the javascript error occurs.

Is there a way to conditionally import the below javascript libraries?

@Import(stylesheet = {
        "context:layout/datatables/css/jquery.dataTables.css",
        "context:layout/datatables/css/dataTables.editor.css",
        "context:layout/tabletools/css/TableTools.css"
},
        library = {
                "context:js/jquery-ui-1.8.19.custom.min.js",
                "context:js/TableTools.js",
                "context:js/dataTables.editor.min.js",
                "context:js/dataTables.editor.commons.js"
        })

I don't want these libraries to be included when I'm not displaying the
datatable.
The second option is to include Tapestry's jquery.dataTables.js and
dataTables.js even in case when I'm not displaying the datatable.

How can this be easily achieved?

Regards,
Lidija


On Wed, Oct 23, 2013 at 7:29 AM, lidijaldo . <lidija....@gmail.com> wrote:

> Hi,
>
> I stumbled upon the next warning a couple of times already and I still
> don't understand why I'm getting it. In our tapestry application we're
> using jquery datatables and it works ok. But in some cases the application
> starts giving me a javascript alert: *"Warning: TableTools 2 requires
> DataTables 1.9.0 or newer - www.datatables.net/download"*.
>
> In the Javascript console I see the following errors:
>
> TypeError: f.fn.DataTable is undefined
>
> ...ools:{});TableTools._aInstances.push(a);return 
> a.dom.container},cFeature:"T",sFe...
>
> TableTools.js (line 76)
> TypeError: j is undefined
>
> ...(){},open:function(){},close:function(){}};f.models.field={className:"",name:nul...
>
> dataTa....min.js (line 13)
> TypeError: $.fn.dataTable is undefined
>
> editor = new $.fn.dataTable.Editor(options);// editor
>
>
>
> This is my tml file:
>
> <html t:type="layout"
>       title="Modules"
>       xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
>       xmlns:h="tapestry-library:jquery"
>       xmlns:p="tapestry:parameter">
>
>     <div class="container">
>         <br style="clear: both;" />
>
>             <t:form t:id="moduleForm" id="moduleForm" class="TTWForm
> ui-sortable" t:type="form" >
>             Choose module:
>                 <select t:type="select"
>                     t:id="selectModule"
>                     t:model="moduleSelectModel"
>                     encoder="moduleSelectEncoder"
>                     t:value="module"
>                     />
>                 <input type="submit" value="Submit"/>
>         </t:form>
>
>         <div class="clear"></div>
>     </div>
>
>     <t:if test="isModuleSelected">
>         <table t:type="jquery/datatable" t:id="najdiEdiDataTable"
> t:source="datasource"
>                        t:row="dataTableRow" t:rowIndex="index"
> t:model="sourcemodel"
>                        t:rowsPerPage="10" t:options="dataTableOptions"
> t:mode="true" />
>     </t:if>
>
> </html>
>
>
> ... Notice the section <t:if test=...>
> I'm trying not to display the datatable if there is no option selected via
> the dropdown menu.
> If I remove the <t:if>, there is no warning and the datatable is always
> displayed. If there is no option selected in the dropdown menu, it is
> empty, which is fine.
>
> So why the javascript error? What does the <t:if> have to do with it?
>
> Thanks in advance,
> Lidija
>
>

Reply via email to