I'm trying to add an override using SPClientTemplates but by the time my custom code calls RegisterTemplateOverrides it's too late, the CSR has already been processed. If I add my custom code to a Script Editor it works fine, but that's not what I want. I need it to be called after other things have been processed, essentially on demand or via callback.

I tried looking at clienttemplates.debug.js but I couldn't see a way to achieve what I need. Perhaps I'm just missing something?

Full disclosure I'm trying to make template modifications using angularjs directives, but again by the time angular has finished bootstrapping, the CSR is taking a nap.

1 Answer 1


I often use CSR to just set up placeholders in the right place on the page that I then access later through the custom IDs that I set. So my CSR scripts look a bit like:

var DEC = DEC || {};

DEC.myOverride = (function () {

  function setUpFields(ctx) {
    // set up placeholders with custom IDs
    html = '<div id="MyDiv_' + ctx.CurrentItem.ID + '"></div>';
    return html;

  function doLaterProcessing() {
    // retrieve the elements based on the IDs i set up earlier
    // and do whatever else I need to with them here.
    // this could include starting off a chain of async calls that
    // eventually populates the elements with data 

  return {
    render: function () {
        Templates: {
          Fields: {
            "MyField": {
              View: setUpFields,
    postProcess: doLaterProcessing

RegisterModuleInit("/path/to/my/OverrideScript.js", DEC.myOverride.render);

// then trigger the later stuff later, either by:

$(window).load(function () {

// or:


Not sure if that will work for you, but that's the technique I use to "use CSR" while still doing a lot of stuff after the CSR rendering has finished.

  • Interesting technique but it doesn't really achieve what I need. I may use this for other things though, thanks!
    – Chad
    Sep 26, 2016 at 18:02

Your Answer

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

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