eddysilvamendes / jquery-star-rating-plugin

Automatically exported from code.google.com/p/jquery-star-rating-plugin
0 stars 0 forks source link

ignore square brackets in element names not working correctly #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use a bracketed value  for a name attribute of a radio button.  Ex: of
test[foo][bar]
2.
3.

What is the expected output? What do you see instead?
Expected output:
<div class="star star_group_data_Line_rating star_live"><a
title="2">2</a></div>

What I see instead:
<div class="star star_group_data_Line][rating] star_live"><a
title="2">2</a></div>

You can see that only the first bracket is being replaced because the g
modifier isn't in there

What version of the product are you using? On what operating system?
version 2.6 on Firefox 3.0.5 on XP

Please provide any additional information below.
This can be fixed by changing line 103 from this:
var n = (this.name || 'unnamed-rating').replace(/\[|\]/, "_");

to this:

var n = (this.name || 'unnamed-rating').replace(/\[|\]/g, "_");

The only remaining problem I'm seeing with my solution is that two brackets
in succession (as in my test[foo][bar] example) results in two underscores
being output, rather than a single underscore.

Original issue reported on code.google.com by douglas....@gmail.com on 23 Jan 2009 at 1:23

GoogleCodeExporter commented 8 years ago
Douglas,
Thanks you so much for the detailed bug report. You've basically done all the 
work.
I changed the regular expression slightly so that 2 consecutive symbols turn 
into 1 
underscore: /\[|\]+/g (note the + and the /g switch you suggested)

I've uploaded these changes so please get the latest version of the code and 
let me 
know if you have any problems.

Original comment by diego.a...@gmail.com on 23 Jan 2009 at 11:35