Inline JavaScript on page include isn't working

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have simple inline JavaScript on my skuid page to remove table component which works fine when I preview this Skuid page. But it does not work when I include this page in other Skuid page via Page include component. Any idea?
Photo of TJ

TJ

  • 952 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
In your Inline JavaScript where it says

skuid.$(function(){

Replace this with

skuid.$(document.body).one('pageload',function(){
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Just a suggestion for the Skuid...

This question comes up over and over again. Perhaps there is a place in the documentation for the Page Include component where you could provide a warning for users with inline javascript?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Matt, understood. One way we are going to help eliminate this problem in the future is to change the default Inline JavaScript code to stop using $(function(){ as the default and to use $(document.body).one('pageload',function() as the default. 
Photo of TJ

TJ

  • 952 Points 500 badge 2x thumb
worked. Thanks Zach!