Javascript error in edit mode

Vote:
 

My 4.62 site has an error that occurs as soon as any page is selected in the page tree in edit mode. This error seems to stop all javascript execution, so I lose the right-click menu etc., which is very annoying. The browser states that the error is in EditPanel.aspx, but it seems to actually come from LanguageSelection.aspx.

The error is

Error: 'EPi' is undefined

and the line reference is to the line theForm.submit(); in the following function:

function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}

Any clues to how I can solve this?

#25093
Oct 13, 2008 14:43
Vote:
 

Hi Magnus!

I am sorry to say I don't have much clues but the "EPi" is undefined refers to a global javascript object we use to encapsulate EPiServer related javascript functionality, but we started to use that in EPiServer CMS 5. I am not completely sure (at home at the moment) but I don't think we use it in 4.62.

If the browser says the error occurs in EditPanel.aspx it means that the error occurs in EditPanel.aspx OR any file referenced in EditPanel.aspx. The line number is almost always correct but it doesn't say which file they mean. So the files (javascript) referenced in EditPanel.aspx are interesting. Did you use script debugger in Visual Studio to get to the line in the __doPostBack function? The script debugger will guide you to the correct line AND the correct file, so it is quite useful and would make it easier to pinpoint what goes wrong.

The __doPostBack function is built into asp.net and yes it contains bugs (my opinion, I guess Microsoft would call it a feature) which I don't like. The if-statement doesn't check for any eventHandlers attached to submit event using attachEvent/addEventListener returning false, which I know we had problems with in EPiServer CMS 5 however solved, but I hope and don't think you have ran into problems with that.

/Regards

#25100
Edited, Oct 13, 2008 20:02
Vote:
 

Thank you for your reply!

I enabled script debugging and found that the error acutally occurs in the context menu constructor in contextmenu.js:

if (!this._IsCrossSite(window.top)) { this.topDocument = EPi.GetDocument(window.top); // the document belonging to the top window this.topWindow = window.top; } 

It is possible that this occurs because there is some mix of EPi4/CMS5 files, since you think that the 'EPi' contanier is only used in CMS5. I have some problems with this since I develop both EPi4 and CMS5 sites on the same computer (for example visual studio sometimes "invents" hundreds of problems that then disappear, and it has a bad habit of adding compilation assembly references in web.config that break the site).

Any idea what I can do to fix it? And is there a good way to develop both for EPi 4 and CMS5 on the same computer?

#25113
Edited, Oct 14, 2008 11:11
Vote:
 

Thanks for clarifying the possible mix of files between EPi4 and CMS 5. It was a real surprise for me to see EPi js object in an EPi4 site. You evidentally use the contextmenu.js from CMS 5 but since you don't have the master page/page base registering all other necessary js files you don't have the EPi object when asking for it.

Setting up development environment for both EPi4 and CMS5 is really not my strong side but it seems a little strange you run into these kind of problems with js files. Could it be that you are using http://localhost and you get contextmenu.js for CM5 served from browser cache?

/Good luck

Henrik

 

#25181
Oct 14, 2008 16:09
Vote:
 
Spot on! Clearing the cache solved the problem. Thank you very much! Laughing
#25195
Oct 15, 2008 7:54
Vote:
 

Happy to be of any help...
Have fun!

/Henrik

#25197
Oct 15, 2008 8:59
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.