1

I have written a function to scroll a Gannt chart to today's date.

The sharepoint file jsgrid.js is registered SOD during init.js and includes the function "ScrollGanttToDate", which I need in my function.

I entered the script below in a script editor webpart, and get the error "Unable to get value of the property 'ScrollGanttToDate': object is null or undefined". The script jsgrid.js has also not loaded at this point.

My question is, why is the execution of my function not being delayed?

<script type="text/javascript">
$(function(){
   SP.SOD.executeOrDelayUntilScriptLoaded(ScrollGanttToToday(),'jsgrid.js');
   function ScrollGanttToToday(){
     $("div [id$='_ListViewWebPartJSGrid']")[0].jsgrid.ScrollGanttToDate(new Date());
   }
});
</script>

Any help would be greatly appreciated.

1 Answer 1

4

You need to remove () while calling the function. Replace below line

SP.SOD.executeOrDelayUntilScriptLoaded(ScrollGanttToToday(),'jsgrid.js');

with

SP.SOD.executeOrDelayUntilScriptLoaded(ScrollGanttToToday,'jsgrid.js');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.