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.
Thank you Nikolay. Your code is very helpful.
Hi, Tangailam.
I'm just checking if you need more help for this issue. Don't hesitate to ask, if you have more questions.
Best regards,
Nikolay Alipiev
Thanks for the sample. I guess it was not on purpose, but there was a exception due to the fact, that the rangeChanged handler was not defined in the ViewModel. Because of that of that reason, the print_first_time parameter was always true and the logic never reached the code where the data was initialized. I fixed that and the check boxes have their default values, when the igDialog is opened. It seems the problem is not related with the igDialog, but I will wait for your feedback for confirmation.
You can find attached the modified sample.
Nikolay
Hi Nikolay,
Thank you for your sample. It worked well but that doesn't solve my problem. I am attaching a code snippet which was extracted from my current project. When the dialog is shown for the first time, the check boxes and radios are checked properly. But once the dialog closed and reopened, they remains whatever user just select before. Would you please have a look at this and let me know your idea? Any comments are really appreciated.
Regards,
Using the sample from that verified post , I've just add a logic to reset the value when the dialog is closed and it is working fine. You can find attached a sample using igCombo, but it should be valid for any controls that have Knockout support. To run the sample you just need to have folder with Ignite UI source code. You can also see the discussion for more information about the igDialog and Knockout. Don't hesitate to ask if you have more questions.