2017-01-23 4 views
0

여기 내 상세 페이지에 내 삭제 코드 :세부 정보 페이지에서 삭제 한 후 목록 페이지로 다시 이동하려면 어떻게해야합니까?

/// <reference path="~/GeneratedArtifacts/viewModel.js" /> 

myapp.ViewReceipt.DeleteReceipt_execute = function (screen) { 

    msls.showMessageBox("Are you sure you want to delete this record?", { 
     title: "Confirm Delete", 
     buttons: msls.MessageBoxButtons.okCancel 
    }) 
    .then(function (result) { 
     if (result === msls.MessageBoxResult.ok) { 
      screen.getReceipt().then(function (receipt) { 
       receipt.deleteEntity(); 
       //Save changes 
       myapp.applyChanges().then(null, function fail(e) { 
        // If error occurs, show the error. 
        msls.showMessageBox(e.message, { title: e.title }).then(function() { 
         // Discard Changes 
         screen.details.dataWorkspace.ApplicationData 
          .details.discardChanges(); 
        }); 
       }); 
       //navigate back to list page 
       this.window.location.href = '#/BrowseReceipts.lsml'; //this doesn't work for me 
      }); 
     } 
    }); 
}; 

답변

1

당신은 myapp.navigateBack() 메서드를 사용하도록 코드를 수정하여이를 달성 할 수 있어야한다.

이 메소드가 실행되어야하는 다음의 수정 예와 같이 applyChanges 성공하면, 자신의 onComplete 콜백을 구현함으로써 완료 :

msls.showMessageBox("Are you sure you want to delete this record?", { 
    title: "Confirm Delete", 
    buttons: msls.MessageBoxButtons.okCancel 
}).then(function (result) { 
    if (result === msls.MessageBoxResult.ok) { 
     screen.getReceipt().then(function (receipt) { 
      receipt.deleteEntity(); 
      // Save changes 
      myapp.applyChanges().then(function onComplete() { 
       myapp.navigateBack(); 
      }, function fail(e) { 
       // If error occurs, show the error. 
       msls.showMessageBox(e.message, { title: e.title }).then(function() { 
        // Discard Changes 
        screen.details.dataWorkspace.ApplicationData.details.discardChanges(); 
       }); 
      }); 
     }); 
    } 
});