"Edit Mode" button

Hi John, i tried wrapping the code as you suggested and that did not help. However, I added some console output statements and drilled down to the error source. It appears that the fieldeditor element does not have the ‘object’ entity in its data collection. Please see my updated script with the console statements and the output of the console in the image attached

var $ = skuid.$; // check for "global" toggle state variable // if it doesn't exist, create it function switchPageMode(){ if(!window.blEditorMode) window.blEditorMode = 'read'; // this will grab any visible field editor // you could also do the same with tables by adding // ", .nx-skootable" to the selector console.log('fieldeditor element: ' + $('.nx-basicfieldeditor:visible')); console.log('fieldeditor.data: ' + $('.nx-basicfieldeditor:visible').data); console.log('fieldeditor.data: ' + $('.nx-basicfieldeditor:visible').data('object')); var fieldeditor = $('.nx-basicfieldeditor:visible').data('object'); if(window.blEditorMode == 'read') { // toggle button text / icon $('.ui-button:visible').has('.ui-silk-pencil').each(function() { $(this).find('.ui-button-text').text('Switch to Read Mode'); $(this).find('.ui-icon').removeClass('ui-silk-pencil') .addClass('ui-silk-book-open'); }); // find all field editors and switch their mode fieldeditor.mode = 'edit' fieldeditor.list.render({doNotCache:true}); window.blEditorMode = 'edit'; } else { // toggle button text / icon $('.ui-button:visible').has('.ui-silk-book-open').each(function() { $(this).find('.ui-button-text').text('Switch to Edit Mode'); $(this).find('.ui-icon').removeClass('ui-silk-book-open') .addClass('ui-silk-pencil'); }); fieldeditor.mode = 'read' fieldeditor.list.render({doNotCache:true}); window.blEditorMode = 'read'; } } $(document).ready(function(){ console.log( "ready!" ); switchPageMode(); } );