Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to use the toChecklist Plugin

Tags:

jquery

xhtml

has anybody used the toChecklist jquery plugin, i am trying to use it and followed the instructions, but nothing happen at all, here is my code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="jquery.toChecklist.min.js"></script>

<!-- Stylesheet -->
<link type="text/css" rel="stylesheet" media="screen" href="jquery.toChecklist.min.css" />

<!-- Code to run toChecklist -->
<script type="text/javascript">
    $(function() {
        $('mySelectBox').toChecklist();
    });
</script>

</head>
<body>

<select id="mySelectBox" multiple="multiple">
    <option>Value 1</option>
    <option>Value 2</option>
    <option>Value 3</option>
</select>   

</body>
</html>
like image 212
Mike Avatar asked Jun 03 '11 02:06

Mike


1 Answers

toChecklist plugin uses two old and obsolete ways to access innerHTML, for examples :

var labelText = $(this).attr('innerHTML'); 
checkboxValue = this.innerHTML;

which is not available in jquery 1.6+

So you have 2 choices to make it work for you.

  1. Downgrade your jquery to version 1.5 or less.
  2. Change those lines (and other lines like this) in toChecklist.js to something like these

    var labelText = $(this).html(); 
    checkboxValue = this.html();
    

Please see http://forum.jquery.com/topic/jquery-change-innerhtml for more details.

like image 156
Chalathip Avatar answered Sep 21 '22 11:09

Chalathip