Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

could you help me with the following problem. I have a html and java code drawing a table below a SharePoint list, in the table I place some calculation based on the list above and it works fine, however if I put the code above the SP list it does not calculate I guess because the site is loaded from the top to down. So can you pls help me how can I solve this problem namely to put the table above the list which would calculate, is there any way to reference a hidden CEWP thru html code? Many thanks!

share|improve this question

2 Answers 2

Move the CEWP below the list.

Alternatively, don't run the javascript until the page has loaded. A common method of doing this is via jquery: http://api.jquery.com/ready/

<html><head> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/JavaScript">
  $(function() {
    // contents of your "go" function here
    // this function will not run until the DOM is loaded
  }); 
</script>

share|improve this answer
    
Can you pls advise how to use this method e.g. I have the below code <html> <head> <script language="JavaScript" type="text/JavaScript"> function go() { ... } </script> </head> </html> –  pmalits Mar 22 '13 at 10:50
    
is there any way to refresh only the CEWP which has the code? –  pmalits Mar 22 '13 at 13:50
    
@pmalits I added an example to my above answer. –  Chloraphil Mar 22 '13 at 14:07
    
I don't understand how refreshing the CEWP would help, can you provide more information about your problem? –  Chloraphil Mar 22 '13 at 14:09
    
I have a SP site built up by different web parts; CEWPs, SP list... I have a CEWP which calualtes based on SP list information, so if the CEWP is above the SP list does not calc since the list below is not loaded, but if I could refesh the CEWP after the SP list is loaded then would solve my proble. I want to keep the CEWP (which is a table with calc fields) above the SP list. Thanks –  pmalits Mar 22 '13 at 14:20

If you are running Javascript and only want it to run only after page loads, put functions inside of document ready section:

$(document).ready(function() {
    //function here
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.