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!
2 Answers
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>
-
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>– pmalitsCommented Mar 22, 2013 at 10:50
-
is there any way to refresh only the CEWP which has the code?– pmalitsCommented Mar 22, 2013 at 13:50
-
-
I don't understand how refreshing the CEWP would help, can you provide more information about your problem? Commented Mar 22, 2013 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– pmalitsCommented Mar 22, 2013 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
});