November Happy Hour will be moved to Thursday December 5th.

JQuery / Javascript issues when previewing in CMS

Vote:
 

At a client's request I've recently added some JQuery to apply rounded corners to a number of images on a site.

This all works fine expect when previewing the page in the backend of the CMS, atwhich point the code still runs, but the results are not as expected!

I've noticed similar things with some JQuery (or maybe JavaScript in general) in the backend, this seems to play up in certain circumstances... maybe when manipulating/adding HTML within the script?

Has anyone encountered this before?

 

#46008
Nov 24, 2010 16:11
Vote:
 

Yes. In most cases this happens because the page isn't visible when the JavaScript code runs. When an HTML-element is hidden it doesn't have a width or height and therefore the script fails.

You can try to add some delay to the script (with setTimeout) when browsing the page in edit-mode.

#46096
Edited, Nov 26, 2010 13:50
Vote:
 

Sorry for the delayed replay, but this method worked a treat.

thanks,

Justin

#47251
Edited, Jan 20, 2011 15:54
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.