locked
stack overflow on line 0 RRS feed

  • Question

  • User-2054142495 posted

    I have this  code below which is a keypad which opens on cell click and you can then insert into the selected cell after youve added a figure and pressed the done button. This works on my local machine however when I open the dialog boxon a test machine in ie8 and click on any of the div buttons i get an error 'stack overflow on line 0'. 

    $(function () {
        $("[id*=grdState] td").bind("click", function () {
            $('[id*=Insert]').val($(this).html());
        });
        return false;
    });
    
    function PersistSelectedValue(selectedValue, siteid, varname) {
        var dbgPoint = 0;
        $.ajax({
            type: 'POST',
            url: 'services.asmx/PostTable',
            data: '{siteid: "' + siteid + '", params:"' + selectedValue + '", varname: "' + varname + '"}',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            async: false,
            success: function (data) {
                $("").html(data.d);
    
            },
            error: function (data) {
                alert("The call to the web services has failed.");
            }
    
        });
    }
    
    function cellClick(event, siteid, varname) {
    
        var myModal = $('#ModalContainer');
    
        var newSelection = $(myModal).find("#txtInsert").val();
    
        //get the actual param values from the hidden input elements in the modal which were set when the modal was displayed
        siteid = $(myModal).find("#hdnSiteID").val();
        varname = $(myModal).find("#hdnVarName").val();
        var className = $(myModal).find("#hdnClassName").val();
    
        
       
        PersistSelectedValue(newSelection, siteid, varname);
        $('#ModalContainer').modal("hide");
        var name = $.trim("." + className.toString());
        var oldValue = $(name).text();
        $(name).text(newSelection);
        var positionArray = className.split("_");
        var oldTotalCount = $("table tr:last").find("td:eq(" + positionArray[1] + ")").text();
        oldTotalCount = parseInt(oldTotalCount);
    
        var newTotalCount = oldTotalCount - parseInt(oldValue) + parseInt(newSelection);
        $("table tr:last").find("td:eq(" + positionArray[1] + ")").text(newTotalCount);
       
    }
    
    function ModalContainer(event, siteid, varname,className) {
        stoptimer();
        var dbg = 0;
        var boundCell = event.srcElement;
        // attempt to find an existing div in the DOM with an id of ModalContainer
        var myModal = $('#ModalContainer');
    
        //if it isn't (i.e. first time of loading) the load it from string
        if (!myModal.html()) {
            myModal = '<div id="ModalContainer"  class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false"><div id="DivModHead" class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="myModalLabel">Update</h3></div><div class="modal-body"><div class="txtInsert"><input type="hidden" id="hdnVarName" value=""><input type="hidden" id="hdnClassName" value=""><input type="hidden" id="hdnSiteID" value=""><input type="textbox" class="myinsert" id="txtInsert" value=""><div style="width: 350px;" id="keys"><div id="key1" style="" class="ui-corner-all mykey" >1</div><div id="key2" style="" class="ui-corner-all mykey">2</div><div id="key3" style="" class="ui-corner-all mykey">3</div><div id="key4" style="" class="ui-corner-all mykey">4</div><div id="key5" style="" class="ui-corner-all mykey">5</div><div id="key6" style="" class="ui-corner-all mykey">6</div><div id="key7" style="" class="ui-corner-all mykey">7</div><div id="key8" style="" class="ui-corner-all mykey">8</div><div id="key9" style="" class="ui-corner-all mykey">9</div><div id="key10" style="" class="ui-corner-all mykey">0</div><div id="keyDel" style="" class="ui-corner-all mykey">Del</div><div id="keyClear" style="" class="ui-corner-all mykey">Clr</div></div></div><div id="keypadbtn"><button id="btnInsert" onclick="cellClick (event, 0, null);"  class="btn" data-dismiss="modal" aria-hidden="true">Done</button></div></div></div>'
    
            $(myModal).modal('show', function () {
                $(myModal).find('#hdnClassName').val(className);
            });
    
            //re-get the object now as a DOM element as opposed to just a string
            myModal = $('#ModalContainer');
    
            //set the values of the textbox and hidden fields which act as params for the siteid and field name 
            $(myModal).find('#txtInsert').val(boundCell.innerText);
            $(myModal).find('#hdnSiteID').val(siteid);
            $(myModal).find('#hdnVarName').val(varname);
            $(myModal).find('#hdnClassName').val(className);
    
            $(".mykey").on("click", function () {
                
                var cntrl = $(this).html();
    
                if (cntrl == 'Clr') {
                    $("#txtInsert").val('');
                }
                else if (cntrl == 'Del' && $("#txtInsert").val().length > 0) {
                    $("#txtInsert").val($("#txtInsert").val().slice(0, -1));
                }
                else {
                    $("#txtInsert").val($("#txtInsert").val() + cntrl + "");
                }
    
    
            });
        }
        else {
            // set the value of the text box before opening the modal popup
            $(myModal).find('#txtInsert').val(boundCell.innerText)
            $(myModal).find('#hdnSiteID').val(siteid);
            $(myModal).find('#hdnVarName').val(varname);
            $(myModal).find('#hdnClassName').val(className);
            $(myModal).modal('show');
        }
    
    }

    I've been at tis all day and any help would be appreciated

    Friday, November 27, 2015 4:17 PM

Answers

All replies

  • User1578460427 posted

    You are missing a semicolon at the end of the following lines of JavaScript:

    myModal = '<div id="ModalContainer"  class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false"><div id="DivModHead" class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="myModalLabel">Update</h3></div><div class="modal-body"><div class="txtInsert"><input type="hidden" id="hdnVarName" value=""><input type="hidden" id="hdnClassName" value=""><input type="hidden" id="hdnSiteID" value=""><input type="textbox" class="myinsert" id="txtInsert" value=""><div style="width: 350px;" id="keys"><div id="key1" style="" class="ui-corner-all mykey" >1</div><div id="key2" style="" class="ui-corner-all mykey">2</div><div id="key3" style="" class="ui-corner-all mykey">3</div><div id="key4" style="" class="ui-corner-all mykey">4</div><div id="key5" style="" class="ui-corner-all mykey">5</div><div id="key6" style="" class="ui-corner-all mykey">6</div><div id="key7" style="" class="ui-corner-all mykey">7</div><div id="key8" style="" class="ui-corner-all mykey">8</div><div id="key9" style="" class="ui-corner-all mykey">9</div><div id="key10" style="" class="ui-corner-all mykey">0</div><div id="keyDel" style="" class="ui-corner-all mykey">Del</div><div id="keyClear" style="" class="ui-corner-all mykey">Clr</div></div></div><div id="keypadbtn"><button id="btnInsert" onclick="cellClick (event, 0, null);"  class="btn" data-dismiss="modal" aria-hidden="true">Done</button></div></div></div>';
    $(myModal).find('#txtInsert').val(boundCell.innerText);



    Friday, November 27, 2015 4:39 PM
  • User61956409 posted

    Hi I-Weedy,

    This works on my local machine however when I open the dialog boxon a test machine in ie8 and click on any of the div buttons i get an error 'stack overflow on line 0'. 

    Firstly, please use other browsers to check if you could get the same error.

    Secondly, please refer to the following links that discussed about this issue.

    http://ccm.net/faq/6657-ie-stack-overflow-at-line-0

    http://stackoverflow.com/questions/226102/stack-overflow-in-line-0-on-internet-explorer

    https://github.com/scottjehl/Respond/issues/86

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 30, 2015 2:49 AM