Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SP2013 - Client Side Rendering : how can I make sure the jquery code runs only when rendering is finished?

$
0
0

HI,

I've created a simple client side rendering file. Basically it displays a field as a slider.

It works fine on my dev environment. But it does not work when I deploy it to my sharepoint online site...

The reason is that the jquery slider code is running before the field rendering itself.

I've tried to use the OnPostRender method but not to avail...

So my question is : how can I make sure the jquery code runs only when rendering is finished?

Here below is my code (reduced to relevant only)

(function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {"MyField": {"EditForm": newRiskEvaluation
        }
    };

    //overrideCtx.OnPostRender = postRenderHandler;
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);

})();


function newRiskEvaluation(ctx) {
    var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx);
    var id = formCtx.fieldName;
    var sliderHtml = "<div id='" + id + "' style='width:100px;float:left;margin-top:7px'></div>";
    return sliderHtml;
}


$(function () {
    $("#MyField").slider();
});


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>