sorich87 / bootstrap-tour

Quick and easy product tours with Twitter Bootstrap Popovers
http://bootstraptour.com
MIT License
4.44k stars 942 forks source link

tour.init() appears unnecessary #700

Open beard7 opened 6 years ago

beard7 commented 6 years ago

The documentation states that init() needs to be called before start(), but as far as I can tell, this is unnecessary: the tour starts perfectly well by just calling start() or restart()

I discovered this is after I removed tour.init() because I was getting an error: Cannot read property 'backdrop' of undefined

Removing tour.init() fixes the error and has no negative consequences.

gfruleux commented 5 years ago

The documentation is correct if you depend on some functions of the Tour before starting it (exemple of getCurrentStep which will be null if you skip the init) But yeah, the tour can start without init because init is called from start if not initialised.

Edit: I knew I missed something ! I removed the following block from the Init method to keep it to initialisation

if (this._current !== null) {
    this.showStep(this._current);
}
IGreatlyDislikeJavascript commented 5 years ago

Doing this does have a negative consequence - it prevents multi page tours, or tours from continuing at previous step after page reload.

My fork fixes this problem. Use my fork, do not call init(). Call start() to begin the tour OR to resume tour from last viewed step. Call restart() to start the tour from first step.

https://github.com/sorich87/bootstrap-tour/pull/710