Closed (fixed)
Project:
Quiz
Version:
6.x-4.0-rc7
Component:
Code - Multichoice
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Jul 2010 at 12:35 UTC
Updated:
17 Aug 2010 at 09:40 UTC
Hello,
When you put the code "print $scripts;" at the end of page.tpl.php template for improving performance on a client side, there is a javascript error "Drupal is not defined".
The problem is the multichoice-alternative.tpl.php template where there is the add script for using the entire alternative row as a button.
To avoid this problem my solution is to move the template code multichoice-alternative.tpl.php line 19-37 in a file in the same place multichoice.js.
The new template-multichoice alternative.tpl.php is (line 13-18):
<?php
$p = drupal_get_path('module', 'multichoice');
drupal_add_css($p .'/theme/multichoice.css', 'module', 'all');
// Add script for using the entire alternative row as a button
drupal_add_js($p .'/theme/multichoice.js', 'module');
The file is multichoice.js:
Drupal.behaviors.multichoiceAlternativeBehavior = function(context) {
$('.multichoice_row')
.filter(':has(:checkbox:checked)')
.addClass('selected')
.end()
.click(function(event) {
$(this).toggleClass('selected');
if (event.target.type !== 'checkbox') {
$(':checkbox', this).attr('checked', function() {
return !this.checked;
});
$(':radio', this).attr('checked', true);
if ($(':radio', this).html() != null) {
$('.multichoice_row').removeClass('selected');
$(this).addClass('selected');
}
}
});
};
Regards
Matthieu
PS: Sorry for my english
Comments
Comment #1
xMATTx commentedOtherwise, another solution inline javascript without having to create a new javascript file.
The new template multichoice-alternative.tpl.php is:
Comment #2
falcon commentedThanks! This has been commitet.
Comment #3
falcon commented