ReferenceError: Can't find variable: jQuery

ReferenceError: Can't find variable: jQuery

fortewebforteweb Posts: 1Questions: 1Answers: 0
edited April 2023 in Free community support

Hi all,

I created a simple page with the basic DataTables example using the CDN. This is using the jQuery initialization.
I can get it to work on this page https://fortewebproperties.com/test/f1/ but not this one. https://fortewebproperties.com/test/f6/

I use Rapidweaver Classic on a Mac with Stacks 5.0 and am upgrading from Foundation 1 to Foundation 6. All that is different is the theme being loaded. I don't understand javascript so I'm unable to get past the error that is shown and how to deconflict it.

The error shown in the Page Inspector Console is
ReferenceError: Can't find variable: jQuery
(anonymous function) — jquery.dataTables.min.js:4:336
Global Code — jquery.dataTables.min.js:4:354
Global Code — f6:56

This is what it points to in the jquery.dataTables.min.js file:

I would appreciate any guidance as I am at a loss on how to attempt to fix this. One other data point is I did also try the non-jQuery init and while the page renders, none of the table buttons function.

Thanks,
Mike

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Hi Mike,

    This one had me for a few minutes. I believe it is being caused by the template tag in the head:

        <template id="plugin-header">
                    [...]
                    <script type='text/javascript' charset='utf-8' src='../../rw_common/plugins/stacks/jquery-2.2.4.min.js?rwcache=702603850'></script>
                    [...]
        </template>
    

    As MDN says:

    The <template> HTML element is a mechanism for holding HTML that is not to be rendered immediately when a page is loaded but may be instantiated subsequently during runtime using JavaScript.

    That would explain why my browser shows jQuery being loaded before DataTables' JS on your page.

    Allan

Sign In or Register to comment.