It adds the onError callback in the settings and is set to $.noop by default.
If the callback returns anything that evaluates to true, trip will stop.
The new callback is called in three distinct cases:
it is called if the trip data is found to be invalid. This is done before the check to skipUndefinedTrip, and if the callback returns true, trip will stop (which addresses the original issue)
it is called if a Deferred object returned by onTripEnd fails in next()/prev()
The next() function was changed a little:
the parameter has been renamed from tripIndex to nextTripIndex to be clearer about which tripIndex is being used.
-The current tripIndex need to be used in the failFilter to the then() call, and is declared as thisTripIndex in both next() and prev().
A draft for the documentation is also included but would certainly benefit from a review.
The skipUndefinedTrip behavior can remain as is (backward compatible) but could be removed in a future release as it can be replaced with a onError() handler returning false for an "invalid trip" message.
This is a proposed change for issue 170.
It adds the onError callback in the settings and is set to
$.noop
by default. If the callback returns anything that evaluates totrue
, trip will stop.The new callback is called in three distinct cases:
true
, trip will stop (which addresses the original issue)Deferred
object returned byonTripEnd
fails innext()
/prev()
The
next()
function was changed a little:failFilter
to thethen()
call, and is declared asthisTripIndex
in bothnext()
andprev()
.A draft for the documentation is also included but would certainly benefit from a review.
The
skipUndefinedTrip
behavior can remain as is (backward compatible) but could be removed in a future release as it can be replaced with a onError() handler returning false for an "invalid trip" message.