Prompt message when Unsaved data while moving to another tab.using "compose"

3 views
Skip to first unread message

karthik k

unread,
Sep 21, 2016, 7:23:23 PM9/21/16
to DurandalJS
Hi,

I Created Tabs using 
<div data-bind="compose: { model: activeTabView, activate:true, activationData: { $data }}"></div>

its working fine, but when am trying to implement canDeactivate method to prompt message for unsaved data changes while user trying to move from one tab to another tab. I am getting alert but it moving to another tab even after clicking "No".



self.canDeactivate = function () {
            var ischanged = false;
            for (var i = 0; self.loggedEquipment() != null && i <self.loggedEquipment().length && !ischanged; i++) {
                ischanged = (self.loggedEquipment()[i].quantity.isDirty() || self.loggedEquipment()[i].regularHours.isDirty() || self.loggedEquipment()[i].overtimeHours.isDirty() || self.loggedEquipment()[i].extraWorkHours.isDirty());
            }
            if (ischanged)
                return app.showMessage('You have unsaved data. Are you sure you want to close?', 'Unsaved Data', ['Yes', 'No']);
            else
                return !ischanged;
        };

please can any one help me on this.

Thanks
karthik

Reply all
Reply to author
Forward
0 new messages