delay the drawing of tables - asp.net

delay the drawing of tables - asp.net

montoyammontoyam Posts: 568Questions: 136Answers: 5

I may be going about this all wrong, but I can't think of an alternative. i have a page with several datatables. Some of them rely on a value from a cookie. I do this in the controller. I have javascript that checks for the cookie and if not set, it displays a form for the user to set the value. The problem is while the form is popped up, the controllers are loading the datatables in the background.

I tried moving the cookie before $(document).ready but the pop-up form needs the document to be drawn. so I have a chicken/egg (or is that a cookie/milk) scenario.

Is there a way to delay the loading of the datatabes until the user clicks submit on the pop-up form? I really hope this post makes sense...it is an ugly scenario.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    Answer ✓

    I would put the Datatables init code inside the submit event handler for your form. To keep the event handler clean place the DT init code in a function and call that function in the handler.

    Kevin

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    oh my goodness. that was so simple. sometimes the obvious is right in front of you and you are too busy looking around it for something more complicated. :blush:

    thanks.

  • montoyammontoyam Posts: 568Questions: 136Answers: 5
        function checkAsOfCookie() {
            AsOfCookie = readCookie("AsOfDate");
            if (AsOfCookie != "" && AsOfCookie != null) {
                $("#AsOf").replaceWith(AsOfCookie);
                $.modal.close();
                drawDataTables();
            } else {
                showAsOfForm();
                //setCookie("AsOfDate", "7/1/2019", 1);
            }
        }
    
  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    sometimes the obvious is right in front of you and you are too busy looking around it for something more complicated.

    Happens all the time :smile:

    Kevin

This discussion has been closed.