Posts Tagged ‘jQuery’

jQuery star rating problem with brackets []


Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/html4strict.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/html.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/html4strict.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/html.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/javascript.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

If you used the star rating plugin of jQuery in cakePHP, you might experienced that the hover effects are not working properly. This is because one of the class name used to identify the buttons uses the radio button name. This will be a problem in cakephp because we use brackets in names.


<input type="radio" name="data[Model][field]" class="star" />

In order to fix that, we need to remove them. Here is quick fix. Open file jquery.rating.js:

from (line 97):


// grouping:
  var n = this.name;

to:


// grouping:
  var real_name = this.name;
  var n = real_name.replace(/[^A-Za-z0-9_\-]/g, '-'); // remove unwanted characters

from (line 108):


$.rating.groups[n].valueElem = $('<input type="hidden" name="' + n + '" value=""' + (settings.readOnly ? ' disabled="disabled"' : '') + '>');

to:


$.rating.groups[n].valueElem = $('<input type="hidden" name="' + real_name + '" value=""' + (settings.readOnly ? ' disabled="disabled"' : '') + '>');

I have reported this in the bugtracker and I hope it will be included in the next release.

Tags: , ,