rhand rhand -4 years ago 145
jQuery Question

jQuery Error using WP Pro Quiz

Just added the WP Pro Quiz and added a quiz locally to test it. When I clicked the button to load the Quiz it is not loaded at all and I got the following error:

Uncaught TypeError: Object [object Object] has no method 'wpProQuizFront'

The script that is loaded after jQuery where the error is located in is:

<script type="text/javascript">
jQuery(document).ready(function($) {
Uncaught TypeError: Object [object Object] has no method 'wpProQuizFront'
quizId: 1,
mode: 0,
globalPoints: 1,
timelimit: 0,
resultsGrade: [0],
bo: 0,
json: {"1":{"type":"cloze_answer","id":1,"points":1,"correct":[]}} });

It is loaded from the file WpProQuiz_View_FrontQuiz.php on line 371:

<script type="text/javascript">
jQuery(document).ready(function($) {
$('#wpProQuiz_<?php echo $this->quiz->getId(); ?>').wpProQuizFront({
quizId: <?php echo (int)$this->quiz->getId(); ?>,
mode: <?php echo (int)$mode; ?>,
globalPoints: <?php echo (int)$globalPoints; ?>,
timelimit: <?php echo (int)$this->quiz->getTimeLimit(); ?>,
resultsGrade: <?php echo $resultsProzent; ?>,
bo: <?php echo $bo ?>,
json: <?php echo json_encode($json); ?>

. Source HTML of Page where quiz is loaded can be seen here: http://pastebin.com/xZVCTxyE To me it seems the code is OK and that $ is coded properly to run, but clearly something is off.

I opened a question at WordPress' Forum, but no answer yet and as this seems to be a script bug not a specific WP issue I decided to ask for help here. Any idea how I can fix this?


Tried a few jQuery no-conflict options like here, but no luck yet still. Even with no.Conflict and or using another variable the error does not go away.

Answer Source

The issue was that I did not have the footer call in my footer.php which is being used by the plugin to load the JavaScript in the footer. I added this snippet for now:

   /* Always have wp_footer() just before the closing </body>
    * tag of your theme, or you will break many plugins, which
    * generally use this hook to reference JavaScript files.

Thought the base theme I worked with was complete, but I was mistaken. Silly me. Al good now!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download