Closed GoogleCodeExporter closed 8 years ago
I wanted to add a follup to this. I have found a workaround.
What I've done is append each <input> tag's name with a unique ID for that
block.
This fixes the non-display issue. However, I can imagine that it will
eventually run
out of memory and crash.
Just wanted to update you.
Original comment by jerryab...@gmail.com
on 13 Apr 2009 at 11:44
Another follow up, sorry.
The workaround works for any window except the first.
Here's what's happening:
1. I make an AJAX call to get a popup window contents that includes the rating.
2. I call $().rating(), which applies the style, injects the new html and hides
the
inputs.
3. jqRating stores the information and notes that this particular element has
been "converted"
4. I close the popup
5. I re-open the same popup, getting the info from AJAX again, new INPUTs but
same
IDs and NAMEs.
6. I call $().rating(), which DOES NOT apply the style because it has cached
the
fact that IDs and NAMEs have had the star style applied.
Make sense?
I'm looking for a way to clear that cache....
Original comment by jerryab...@gmail.com
on 14 Apr 2009 at 2:47
Hey there. I patched the code to get around my problem. Not sure you've looked
at it
yet.
Here's what I did:
1. Created a new option called 'resetAll', boolean:
resetAll: false, // Forces a reset when loading...
2. I changed the declaration of 'raters' to look at 'resetAll':
var raters = ( options.resetAll ? { count:0 } : context.data('rating') || {
count:0 } );
3. Lastly, right after all the variable declarations, I set 'resetAll' to false:
options.resetAll = false;
This seems to work just peachy. As I stated earlier, I'm not sure if this will
result in memory leakage over time, but JS is supposed to GC right?
Original comment by jerryab...@gmail.com
on 16 Apr 2009 at 4:38
Sorry, here's my copy of the code...
Original comment by jerryab...@gmail.com
on 16 Apr 2009 at 4:40
Attachments:
Hi Jerry,
Thank you for your efforts to resolve this issue and thank you very much for
reporting your progress. The root of the problems here seem to be that you're
"not
quite" using valid markup.
1st: all input elements must have a 'name' parameter - the plugin depends on
this in
order to identify/separate element sets. it would not be sufficient for the
plugin to
generate unique names because there is not safe way of assuming where a set of
radio
buttons begins/ends unless they have 'name'.
2nd: you may have several group with the same 'name' parameter on the same
page. the
plugin differentiates between these groups by caching the control settings on
their
containing form (the form the elements belong to) - this is the scope of the
plugin.
In this case, your problem is that you are not inserting the input elements
within a
form. And because of that, the plugin stores the controls setting on the body
tag -
this then becomes the scope of the plugin.
Your patch will work. As you correctly pointed out, there is a risk it could
create
huge memory leaks over-time (specially in an application such as yours) but I
doubt
this will be the case. That's because whatever settings were stored about the
old
plugin will be overwritten by the new plugin (of your second call).
However, your fix may create an even bigger problem. If you use the resetAll
parameter to create a new control with the same name, but the previous control
has
not yet been removed, the first control would stop working because its settings
in
the container would be replaced with the new settings (and functionality).
It works for you because you are replacing the html (and removing the previous
elements) but it cause problems if you were appending the code.
But, I think there's a way of doing this automatically, without the risk of
breaking
previously created plugins. And the method is to make each call to the plugin
unique
by adding a serial number to the internal control ID.
This way no additional settings will be required (no user input) and we save a
little
code... I'll post back when it's ready!
Original comment by diego.a...@gmail.com
on 16 Apr 2009 at 8:54
Done! Please follow the twitter account for future updates:
http://twitter.com/fyneworks
Original comment by diego.a...@gmail.com
on 16 Apr 2009 at 9:27
Original issue reported on code.google.com by
jerryab...@gmail.com
on 13 Apr 2009 at 11:32