How to Clear Contents of an observableArray That was Populated from Previous Visits to a View

前端 未结 4 1241
猫巷女王i
猫巷女王i 2021-02-06 20:59

I have a Single Page Application that uses knockout for the data binding. The CAApproval.html view in my single page application has an observeablearray named AllCertificates i

4条回答
  •  清歌不尽
    2021-02-06 21:49

    Just set it equal to nothing (allCertificates([])) in your activate function, which is called each time your view model loads -

    function(logger, system, router, CertificateDataService) {
        var allCertificates = ko.observableArray();
    
    var activate = function () {
        allCertificates([]);
        // go get local data, if we have it
        return SelectAllCerts(),SelectMyCerts(), GetCertificateDetails(), GetDDABankNums();
    };
    
    var vm = {
        activate: activate,
        allCertificates: allCertificates,
        SelectAllCerts: SelectAllCerts
    });
    

提交回复
热议问题