Doesn't work under konqueror (slice function on object?)

karlmoritz - May 8, 2008 - 11:08
Project:jRating
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi there,
I've just updated to the dev version due to some issues with the 1.0 release, and now the javascript doesn't seem to function properly anymore. I'm not entirely sure if this is a konqueror only problem (no other browser around to check with, unfortunately), but it seems that the stars.slice function breaks the code.

I've tried to debug this inserting various alerts, to figure out exactly what is happening, and in every case it's the stars.slice call that ends the execution of the script. alert(stars) gives me "[object Object]" - perhaps that could be the problem, as I thought the slice function needs an [array Object] instead?

Will continue trying to figure this out, but would appreciate any help on this, as I'm not very good with javascript myself..

Cheers
kmh

#1

karlmoritz - May 8, 2008 - 11:25

Fixed the problem by replacing the slice function with for-loops in all the occurences.

        function fill(elem){
            stars.find("a").css("width", "100%");
            for (var i = 0; i < stars.index(elem) + 1; i++)
              $(stars[i]).addClass("hover");
        }
...
        function reset(){
          for (var i = 0; i < averageIndex; i++) {
            $(stars[i]).addClass("on"); }
...


and in
function rating_submit_rating(id){
...
        for (var i = 0; i < mean[0]; i++)
          $(stars[i]).addClass("on");

Perhaps not the most elegant fix, but it works.

Thanks for a great module, by the way, really appreciate it!

 
 

Drupal is a registered trademark of Dries Buytaert.