Multiple "data('object').editor" editors

edited March 2, 2017 in Questions
I have used custom error messages with page titles in the past with the following syntax:

var pageTitle = $('#MyPageTitle');       
var editor = pageTitle.data('object').editor;
editor.handleMessages([{message:'Account billing address is incomplete', severity:'ERROR'}]);

I recently tried using 2 different page titles with 2 different Ids to have 2 different error message locations like so:

var pageTitle = $('#MyPageTitle');       
var editor = pageTitle.data('object').editor;
editor.handleMessages([{message:'Account billing address is incomplete', severity:'ERROR'}]);
var errorPageTitle = $('#MyErrorPageTitle');
var errorEditor = errorPageTitle.data('object').editor;
errorEditor.handleMessages([{message:'Account billing address is incomplete', severity:'ERROR'}]);

It seemed to work for a bit, but recently I've been getting errors on this line:

var errorEditor = errorPageTitle.data('object').editor;

that editor can't be read/ it's undefined. Can this not be used 2 times on one page?

        

Comments

  • edited March 2, 2017
    If it's breaking on that line, that means that errorPageTitle.data('object') is what's undefined, not .editor, so I would check to make sure that the errorPageTitle is in fact present, e.g. do this:

    var errorPageTitle = $('#MyErrorPageTitle');
    console.log(errorPageTitle);

    and see if anything comes up for errorPageTitle, or if it's undefined / an empty list. If so, then check the Unique Id on your Page Title to make sure it's correct.

  • edited December 18, 2014
    Thanks Zach it was a problem with the Unique Id, sometimes you forget about the little things... thanks for your help.
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!