My view is strongly typed to a CalculateModel
where a user inputs information and then makes an ajax
post to the controller. The controller performs calculations using this data and returns a PartialView strongly typed to the ResultCalculateModel
.
The Result partial view contains a dynamically generated d3 chart
with parameters from the ResultCalculateModel
. Here is some code snippet:
@model DTO.CalculateModel
//html helpers here for user input
<div id='divOutPutData'> </div>
<script>
function getResult() {
$.post("/GetResult", $('#form01').serialize())
.success(function (result) {
$('#divInputData').attr('style', 'display:none');
$('#divOutPutData').append(result);
};
function drawChart(s,p,c){
//code
};
</script>
The controller action:
public ActionResult GetResult(CalculateModel model)
{
ResultCalculateModel result = _calculateResult.Calculate(model);
return PartialView("Result", result);
}
The result Partial View:
@model DTO.ResultCalculateModel //the parameters of the drawChart function are in this model.
//some Razor Helpers which is working
<div id="chartResult"> </div> //display the chart here
I am looking for a way to execute the drawChart
function when rendering the partial view.