好问题。我建议结束之前的更改跟踪器并开始一个新的跟踪器,如下所示:
// Keeps track of trackers
var curTrackerNbr = 0;
var curTracker = null;
var syncTracker = null;
function getChangeTracker() {
return db.changeTrackers.create("orders_tracker_" + curTrackerNbr, ["orders_table", "invoice_table"]);
}
function beginSync() {
// end current tracking, start new one
syncTracker = curTracker;
syncTracker.endTracking();
// creating a tracker automatically turns it on...
curTracker = getChangeTracker();
// Get data to be sync'd
var syncData = syncTracker.getChangedRows();
// Perform sync
syncDataToServer(syncData, onSyncSuccess, onSyncFailure);
}
function onSyncSuccess() {
// remove the syncTracker (for cleaning purposes)
db.changeTrackers.drop(syncTracker.name);
}
function onSyncFailure() {
if (window.confirm("Want to try again?")) {
var syncData = syncTracker.getChangedRows();
syncDataToServer(syncData, onSyncSuccess, onSyncFailure);
}
}
// Now, let's create our first change tracker.
curTracker = getChangeTracker();
我希望上面的代码比我的话能更好地解释它!
约翰...