In ASP.NET, I would have an ascx control, and it would call Scriptmanager.RegisterClientScriptBlock in its own Load() method.
I'd have a block of javascript like
var myObject = CreateNewMyObject(param, param, param...);
which would be a method in my javascript library to go off and create the control on the page.
However in MVC I have never done this before so I am unsure what to do.
I can call a method such as @(this.Html.RenderMyObject(param, param)) which will return fully rendered html, but I want to do it as above - the javascript function renders the html.
Should I return var myObject = CreateNewMyObject(param, param, param...); from a method like this, or is there a much nicer way?