inline javascript not running on salesforce site

Matt SonesMatt Sones 💎💎💎
edited May 23, 2018 in Questions
This inline javascript:
(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
   console.log('Page Loaded');
});
})(skuid);
When I run the page with the skuid preview, it works fine. When I run it visual force on a salesforce Site, the code doesn't execute and my console is blank.

Comments

  • Matt SonesMatt Sones 💎💎💎
    edited July 12, 2017
    I'm on skuid 8.15.15
  • edited July 13, 2017
    $(document.body).one(

    should be 

    $(document.body).on(
  • Matt SonesMatt Sones 💎💎💎
    edited July 12, 2017
    Thanks, Pete. Neither works.
  • edited July 12, 2017
    try:

    $(document).ready(function() {
        console.log("hello world");
    });
  • edited July 12, 2017
    try

    $(document).ready(function(){
        console.log('page loaded');
    });
  • Matt SonesMatt Sones 💎💎💎
    edited July 13, 2017
    No, the problem is not the ready function itself. The problem is that the script isn't being called at all.
  • Matt SonesMatt Sones 💎💎💎
    edited July 13, 2017
    Skuid-- any ideas on this?

    I have an inline javascript resource like the following, which runs fine in salesforce but on on a salesforce site:
    (function(skuid){
        console.log('script loaded');
    })(skuid);
  • Amy DewaalAmy Dewaal ✭✭
    edited May 23, 2018
    Matt,

    Try using $(".nx-page").one("pageload",function() { instead of $(document.body).one('pageload',function(){ - oh, just realized you said the snippet isn't getting called at all, so that won't help you. Do you see any errors in the browser console?
  • Matt SonesMatt Sones 💎💎💎
    edited July 13, 2017
    No errors in the console.
  • Matt SonesMatt Sones 💎💎💎
    edited July 13, 2017
    Is there something about force.com sites that I need to do differently? Is there some kind of security setting that could be getting in the way?

    Searching through the salesforce documentation and forums hasn't gotten me anywhere.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!