Jump to content

Can i include php datatables third party script in block code?


Jyoti Rani
Go to solution Solved by Nathan Explosion,

Recommended Posts

  • Solution

OK - first bit of advice...you don't need this as jQuery (v3.7.0) will be provided by Invision's software:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

Secondly...in your screenshot, the error is $(...).DataTable but when I view the site, I see:

$(...).dataTable is not a function

The DataTable function is called "DataTable" so if you have do have it as "dataTable" in your code then correct that.

Finally though, and most important...your code is BEFORE the code that loads up all of Invision's JS. That is possibly why you decided to include that first line of script to load jquery up. You can change that in your theme settings:

Could contain: Page, Text

 

Link to comment
Share on other sites

32 minutes ago, Nathan Explosion said:

OK - first bit of advice...you don't need this as jQuery (v3.7.0) will be provided by Invision's software:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

Secondly...in your screenshot, the error is $(...).DataTable but when I view the site, I see:

$(...).dataTable is not a function

The DataTable function is called "DataTable" so if you have do have it as "dataTable" in your code then correct that.

Finally though, and most important...your code is BEFORE the code that loads up all of Invision's JS. That is possibly why you decided to include that first line of script to load jquery up. You can change that in your theme settings:

Could contain: Page, Text

 

Could contain: File, Page, Text, Webpage

I have updated the code above But its not reflecting.

For datatable i checked the Datatable Capital (D) issue as well. Still no luck. Any other ways to resolve this ?

Link to comment
Share on other sites

OK - I didn't mention anything about putting those items in the footer of the theme so that's your call.

And you haven't modified the theme setting that I indicated you could change.

And now you have this as your code

<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script> -->
    <script type="text/javascript">
      jQuery.noConflict();
        jQuery(document).ready(function() {
            jQuery('#example123').DataTable({
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": "https://beta.marketingcheckpoint.com/admin/mailing/ajax_mail_history_dt10.php"
            });
        });
    </script>

And this as your error:

Could contain: Text, Page

Why? You've commented out BOTH the jquery line and the datatables line, and you aren't loading the datatables JS at a later point. Plus you are using "jQuery" instead of "$"

Use this code in the block, modify the theme setting I indicated, and then advise if it doesn't work:

 

<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#example').DataTable({
          "bProcessing": true,
          "bServerSide": true,
          "sAjaxSource": "https://beta.marketingcheckpoint.com/admin/mailing/ajax_mail_history_dt10.php"
		});
	});
</script>

 

 

Link to comment
Share on other sites

49 minutes ago, Nathan Explosion said:

OK - I didn't mention anything about putting those items in the footer of the theme so that's your call.

And you haven't modified the theme setting that I indicated you could change.

And now you have this as your code

<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script> -->
    <script type="text/javascript">
      jQuery.noConflict();
        jQuery(document).ready(function() {
            jQuery('#example123').DataTable({
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": "https://beta.marketingcheckpoint.com/admin/mailing/ajax_mail_history_dt10.php"
            });
        });
    </script>

And this as your error:

Could contain: Text, Page

Why? You've commented out BOTH the jquery line and the datatables line, and you aren't loading the datatables JS at a later point. Plus you are using "jQuery" instead of "$"

Use this code in the block, modify the theme setting I indicated, and then advise if it doesn't work:

 

<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#example').DataTable({
          "bProcessing": true,
          "bServerSide": true,
          "sAjaxSource": "https://beta.marketingcheckpoint.com/admin/mailing/ajax_mail_history_dt10.php"
		});
	});
</script>

 

 

I have tried with $ as well. Also done the RnD with the suggestion you have shared. 

I have changed like as you have suggested. But still no luck.

Link to comment
Share on other sites

18 minutes ago, Nathan Explosion said:

You still have this in your code - remove it. - Its Removed

 <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

 

Could contain: Page, Text, Chart, Plot

You also still have your JS loading set to "Just before the </body> tag" - change it to the setitng I mentioned. - In my invision default theme. Not able to find the settings which you have shared. Can you please share any link for this?

 

My theme is invision default theme.

Link to comment
Share on other sites

Hello Nathan,

I have a new Query here. 

Could contain: File, Webpage, Page, Text

I have an simple HTML form. I want to use jquery validate. But its showing the above error.

I just included     <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script> this file in my code. and used the basic validations there. Can you please suggest whats wrong here. 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...