Page Load Snippets stopped working- Brooklyn

  • 2
  • Problem
  • Updated 2 years ago
  • Solved
All of our page load snippets don't appear to work in Brooklyn.  I've got a simple example where I expect to see a console log message, and I get nothing.


Example snippet:
(function(skuid){ var $ = skuid.$;
$(document.body).one('pageload',function(){

console.log("Page load snippet is running");
});
})(skuid);


Page XML:
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Account">    <models>
        <model id="Account" limit="1" query="true" createrowifnonefound="false" datasourcetype="salesforce" datasource="salesforce" sobject="Account">
            <fields>
                <field id="Name"/>
                <field id="CreatedDate"/>
            </fields>
            <conditions>
                <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="Account" uniqueid="sk-1hQM8r-97">
            <maintitle>
                <template>{{Name}}</template>
            </maintitle>
            <subtitle>
                <template>{{Model.label}}</template>
            </subtitle>
            <actions>
                <action type="delete"/>
                <action type="clone"/>
                <action type="share"/>
                <action type="savecancel" window="self"/>
            </actions>
        </pagetitle>
        <basicfieldeditor showsavecancel="false" showheader="true" model="Account" mode="read" uniqueid="sk-1hQM8r-98">
            <columns>
                <column width="50%">
                    <sections>
                        <section title="Basics">
                            <fields>
                                <field id="Name"/>
                            </fields>
                        </section>
                    </sections>
                </column>
                <column width="50%">
                    <sections>
                        <section title="System Info">
                            <fields>
                                <field id="CreatedDate"/>
                            </fields>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript>
            <jsitem location="inline" name="pageLoad" cachelocation="false" url="">(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){

console.log("Page load snippet is running");
});
})(skuid);</jsitem>
        </javascript>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb

Posted 2 years ago

  • 2
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Chandra,

What iteration of Brooklyn are you on?
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb
I just installed this morning, so 9.3.1
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb
Org ID and access provided to Skuid support team via email.
Photo of Chandra Sekhar

Chandra Sekhar

  • 496 Points 250 badge 2x thumb
Hi Chandra V ,

Is this Issue fixed? As we're also facing same Issue.

regards,
Chandra A.
Photo of Daniel Camp

Daniel Camp

  • 372 Points 250 badge 2x thumb
Chandra is out today but issue is not resolved.
Photo of Chandra Sekhar

Chandra Sekhar

  • 496 Points 250 badge 2x thumb

Thank you Daniel.

We have been searching for work arounds until skuid Team can fix it. 

One work around for now is using "$(document).ready(function(){"  instead of "$(document.body).one('pageload',function(){" in Inline snippet. We are still testing all our scenarios.


 Hope this may help !!


regard's,

Chandra A


Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
One warning: using $(document).ready() instead of triggering on the first pageload won't work for page includes. It is only triggered once on initial page load, so any included pages that need to run inline javascript when they're loaded will continue to fail.
Photo of Daniel Camp

Daniel Camp

  • 372 Points 250 badge 2x thumb
The code we have in a page where it is not working was as follows:

(function(skuid){

                var $ = skuid.$;

                $(document.body).one('pageload',function(){

                                //var myModel = skuid.model.getModel('MyModelId');

                                //var myComponent = skuid.component.getById('MyComponentUniqueId');

                               

                                skuid.snippet.getSnippet('ClearUserFields')();

                                console.log('page load snippet has run');

                });

})(skuid);

 

When we replace:

$(document.body).one('pageload',function(){

 With :

 $(window).on('load',function(){

 

It works fine. Honestly don't understand what that statement means but it runs on page load. Another user within our company was using this code successfully.

Hope this helps.
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Hi All,

Just wanted to let you know that our developers are currently working on this, and the fix is targeted to be out in the next release. Thanks for your patience, and for sharing your workarounds with each other!
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Hi All,

This issue is now fixed in Brooklyn Iteration 3, available from our Skuid Releases page. As a reminder, Salesforce does not allow reverting back to prior versions of managed packages. Skuid always recommends installing new versions in a non-business critical sandbox environment to test all mission critical functionality before installing into a production environment. We also recommend that you update out of date themes when you upgrade.

Thanks!
Amy