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.

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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