MyCademy / yii2-bootstrap-tour

Yii 2 Bootstrap Tour Extension
Apache License 2.0
3 stars 5 forks source link

Uncaught TypeError: Cannot read property 'start' of undefined at HTMLButtonElement.onclick #10

Open KalyaniKatariya opened 7 years ago

KalyaniKatariya commented 7 years ago

$tour = new Tour([ 'scope' => 'window', //Set scope to make the 'tour' variable global 'startMode' => Tour::START_MODE_FORCE_START, //initialize and force start the tour 'clientOptions' => [ //Bootstrap Tour Options, see: http://bootstraptour.com/api/ 'steps' => [ [ 'element' => "#h1", 'title' => "Step 1", 'content' => "Content of my step 1", 'backdrop' => "true", ], [ 'element' => "#h2", 'title' => "Step 2", 'content' => "Content of my step 2", ], ], 'storage' => "false" ], ]);

$tour->run();

echo Html::button('Start the tour', ['onclick' => $tour->getVarName().'.start(true);' //use $tour->getVarName() to get the reference to the 'tour' var name ]); I am trying to run the tour manually. I have written the code in view file. When I run the code in console I am getting Error - VM1152 :459 Uncaught TypeError: Cannot read property 'start' of undefined at HTMLButtonElement.onclick (VM1152 :459). I have checked the bootstrap tour css and JS files are getting loaded in browser. But in console I am getting this error. Can you please help?

rhertogh commented 7 years ago

Can you provide the generated html code

KalyaniKatariya commented 7 years ago

Hi Here is the generated HTML code - `

Quester

Congratulations!

Welcome to Let's Quester - Platform for Inquiry oriented learners !

Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Yii Documentation »

Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Yii Forum »

Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Yii Extensions »

})();

Here is the generated HTML for my view file - `

KalyaniKatariya commented 7 years ago

I also checked Firefox console logs it mentions - ' window.tour is undefined'