Function JavaScript does not work after the second call (and subsequent)

0

I have a very strange problem. I am developing a functionality in C # with MVC 3. When clicking on a tab, the controller returns a partial view and in turn this view calls a javascript file that draws a graph. The first time the system is seen, the system works perfectly, the JS files run normally. But if I click on that tab again (or go to another one and come back), those files are no longer executed. Debugging the code, I see that effectively the view is executed and the lines calling the JS methods also , but inexplicably the control never passes to these files. The weirdest thing is that the Chrome console does not return any error

I have the following code in my view (aspx):

            <div class="widget-content">

            <div id="containerWidgetTension" style="height: 300px; min-width: 310px; text-align: center; font-weight: bolder"></div>
            <%
                UrlAccion = Url.Action("GetSerieGraficoTension", "Terminales");
            %>


            <script src="content/JS/Graficos/graficotension.js" type="text/javascript"></script>
            <script type="text/javascript">
                function WidgetTension() {
                    var param = {
                        accion: '<%= UrlAccion %>',
                        container: 'containerWidgetTension',
                        terminal: '<%= vd.Terminal.NumeroDeSerie %>',
                        fechaDesde: '<%= fechaHasta %>',
                        fechaHasta: '<%= fechaHasta %>',
                        valorConstante: '<%=ViewBag.ValorConstanteTension%>',
                        TT: '<%= vd.Terminal.TT %>'
                    }

                    MostrarGraficoTension(param);
                };

                $(function () {
                    WidgetTension();
                });
            </script>
        </div>

And the Javascript function is in a separate file called graficotension.js:

function MostrarGraficoTension(param) {

accion = param.accion;
terminal = param.terminal;
fechaDesde = param.fechaDesde;
fechaHasta = param.fechaHasta;
monofasico = param.monofasico;
mostrarUmbrales = param.mostrarUmbrales;
umbralTensionMaxima = param.umbralTensionMaxima;
umbralTensionMinima = param.umbralTensionMinima;
valorConstante = param.valorConstante;
TT = param.TT;
var container = param.container;

function createChart(data) {

    (resto del codigo)

var url = accion;
var parametros = "?Terminal=" + terminal + "&FechaDesde=" + fechaDesde + "&FechaHasta=" + fechaHasta;
url = url + parametros;

$.getJSON(url, function (data) {
    createChart(data);
}).fail(function(jqXHR, status, error){
    $('#' + container).css('cursor', 'default');
    $('#' + container).text("Error cargando la serie.");

    var errorStr = "Error - " + status  + " - " + error;
    console.log(errorStr);
    console.log(jqXHR.responseText);
}); 

};

Thank you very much!

    
asked by ZottoSL 19.10.2018 в 17:26
source

0 answers