Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
645
igDialog and Knockout js
posted

Hi,

I have a dialog with controls inside bound with Knockout. Everything works well for me except one thing: once user made some changes on dialog (like check some check boxes, type in some text) then close it, next time all the changes remain. To close the dialog, I just use this function: $("#print-dialog").igDialog("close");. Did you see this issue before and if yes, what was your solution to fix this?

FYI, my function to open the dialog follows:

function showPrintDialog(exam_id, exam_type) {

    if (print_first_time == true) {

        print_model = new printDialogViewModel(exam_id, exam_type);
        ko.applyBindings(print_model, document.getElementById('print-dialog'));

        $('#print-questions').customRadioCheck();
        $('#print-answers').customRadioCheck();
        $('#print-explanations').customRadioCheck();
        $('#print-answer-key').customRadioCheck();
        $('#print-blank-answer-sheet').customRadioCheck();

        $('#print-range-text').igTextEditor();
        $('#print-range-text').igTextEditor("option", "disabled", true);
        $('#print-exam-print-btn').igButton();
        $('#print-exam-cancel-btn').igButton();

        print_first_time = false;

    } else {
        // reinitialize the data
        print_model.Questions(true);
        print_model.Answers(true);
        print_model.Explanations(true);
        print_model.AnswerKey(false);
        print_model.BlankAnswerSheet(false);
        print_model.QuestionRangeText = ko.observable("");
        $('#print-range-text').igTextEditor("option", "disabled", true);
    }

    $("#print-dialog").igDialog("open");

    $(function () {

    });
}

Thanks in advance.

Parents
No Data
Reply
  • 4315
    Offline posted

    Hi, Tangailam.

    Thanks for using our product. I just have one question to clarify if I understood you right.

    When the igDialog is closed, the container is just hidden, it's not destroyed. That's why when it's opened again, the container is just shown again, and nothing of the controls, bound with Knockout, is changed. Is your expectation that all the controls are with default values? Because igDialog closing/opening is not related and should not affect the Knockout functionality.

    I will wait for your feedback and sorry if I didn't understand your question. 

    Best regards,

    Nikolay

Children