zurb / joyride

jQuery feature tour plugin.
http://www.zurb.com/playground/jquery-joyride-feature-tour-plugin
1.42k stars 241 forks source link

post_ride_callback Uncaught TypeError: string is not a function (Solved) #201

Closed markdrake closed 9 years ago

markdrake commented 9 years ago

Hello, I'm trying to execute a callback after the tour ends but it's not allowing me. The tour works fine but every time I click on the end button I get the following error:

Uncaught TypeError: string is not a function

My initialization code:

$(document).foundation('joyride', 'start', { post_ride_callback: function() { console.log("Tour ended"); } });

My stacktrace:

Uncaught TypeError: string is not a function: joyride_foundation.joyride.js:915 Foundation.libs.joyride.end: joyride_foundation.joyride.js:69
Foundation.libs.joyride.go_next:joyride_foundation.joyride.js:102 (anonymous function) jquery.js:4409 jQuery.event.dispatch jquery.js:4095 jQuery.event.add.elemData.handle

The exact line with the error:

if (typeof abort === 'undefined' || abort === false) { this.settings.post_step_callback(this.settings.$li.index(), this.settings.$current_tip); this.settings.post_ride_callback(this.settings.$li.index(), this.settings.$current_tip); // this is the 915 }

markdrake commented 9 years ago

An additional comment, If I change the name in the settings from post_ride_callback to post_step_callback the same exact function is executed without a problem. My workaround will be to evaluate the index and if I'm at the last element expected execute my original intent.

markdrake commented 9 years ago

Well, silly me, I forgot to clean my HTML markup and left an initializer in my data-options which probably caused the duplication and confused the library. My bad. Please close this issue and delete it if possible :)