Queue + Page Include console error: cannot read property 'registerEditor' of undefined

edited December 4, 2017 in Questions
I have a detail page using a queue component, which is trying to load a page include. The page I'm including contains an inline resource which is resulting in an error in the console. (see attached screenshot) as well as preventing the page include from loading. The included page and snippet works fine on its own as a detail page, but as a page include its not working.

Does a page include in a queue component not have the full functionality of a normal detail page? ie should it be read only? 

Is there another way to make this snippet work inside the page include component?

image

Comments

  • edited December 4, 2017
    here is the inline resource which is running fine in my Quote page, except for when I use that page as a page include component:

    skuid.$(function(){ 
    var FleetQuote = skuid.model.getModel('FQuote'), 
    FleetQuoteSectors = skuid.model.getModel('FSectors'); 

    var listener = new skuid.ui.Editor(); 
    listener.handleSave = function() { 
    if (!FleetQuote.hasChanged) { 
    FleetQuoteSectors.updateData(); 

    }; 
    listener.registerModel(FleetQuote); 
    }); 

    skuid.$(function(){ 

    var FleetQuoteSectors = skuid.model.getModel('FSectors'), 
    FleetQuote = skuid.model.getModel('FQuote'); 

    var listener = new skuid.ui.Editor(); 
    listener.handleSave = function() { 
    if (!FleetQuoteSectors.hasChanged) { 
    FleetQuote.updateData(); 

    }; 
    listener.registerModel(FleetQuoteSectors); 
    }); 


  • Zach McElrathZach McElrath Principal Software Engineer Chattanooga, TN 💎💎💎
    edited March 2, 2017
    The trick with JavaScript run in included Pages is that the jQuery document.ready() handler (e.g. the skuid.$(function(){ }); construct you're using here) does not work, because the main document is already ready when your Page Include is loaded, and hence your JavaScript will be run immediately --- before the Page Include's document is ready, and before Skuid has finished setting up the Models in the included Skuid page.

    So, what to do?

    Register on a different event.

    You'll need to replace the skuid.$(function(){}); construct with skuid.$(document.body).one('pageload',function(){}), like this:


    skuid.$(document.body).one('pageload',function(){ 
    var FleetQuote = skuid.model.getModel('FQuote'), 
    FleetQuoteSectors = skuid.model.getModel('FSectors'); 
    var listener = new skuid.ui.Editor(); 
    listener.handleSave = function() { 
    if (!FleetQuote.hasChanged) { 
    FleetQuoteSectors.updateData(); 

    }; 
    listener.registerModel(FleetQuote); 
    }); 

    skuid.$(document.body).one('pageload',function(){ 
    var FleetQuoteSectors = skuid.model.getModel('FSectors'), 
    FleetQuote = skuid.model.getModel('FQuote'); 
    var listener = new skuid.ui.Editor(); 
    listener.handleSave = function() { 
    if (!FleetQuoteSectors.hasChanged) { 
    FleetQuote.updateData(); 

    }; 
    listener.registerModel(FleetQuoteSectors); 
    }); 
  • edited December 4, 2017
    works perfectly. Thanks Zach.
  • edited December 4, 2017
    as an extension of this, is it possible to update the queue model (and display template), after fields in the page include are updated?

    ie have a listener which listens for changes in the page include models, and updates the model in the parent page, which the queue is based on?
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!