• We recently tried to use YASR on mobile, but we found that people gets stuck when trying to submit a rating on mobile. It works fine on desktop. The error on mobile can also be seen on Chrome inspect (device needs to be set to a mobile device), and the error looks like this:

    “yasr-front.js?ver=2.0.3:213 Uncaught TypeError: Cannot read property ‘toFixed’ of undefined
    at Object.rateCallback (yasr-front.js?ver=2.0.3:213)
    at Object.onStarClick (rater-js.js?ver=2.0.3:150)”

    We did some further study, and realized that the error is because of a conflict between YASR and WPTouch. Here is our fix, and it works fine on our website. In rater-js.js, near callback !== "undefined" , add the following code:

    
                        // debug
                        console.log("rater-js.js:onStarClick():e:",e);
    ?
    ?
                        if (typeof callback !== "undefined") {
                            isRating = true;
                            myRating = currentRating;
    ?
                            // for wptouch hack start ----->
                            if (myRating == undefined || myRating == null) {
                                // console.log("onStarClick():myRating is need hack for wptouch.");
                                var xCoor = e.offsetX;
                                var width = elem.offsetWidth;
                                var percent = xCoor / width * 100;
    ?
                                if (percent < 101) {
                                    if (step === 1) {
                                        currentRating = Math.ceil(percent / 100 * stars);
                                        // console.log("onStarClick():step=1,currentRating:",currentRating);
                                    } else {
                                        var rat = percent / 100 * stars;
            
                                        for (var i = 0; ; i += step) {
                                            if (i >= rat) {
                                                currentRating = i;
                                                break;
                                            }
                                        }
                                    }
                                }
                                myRating = currentRating;
                            }
                            
                            // console.log("onStarClick():myRating:",myRating);
                            // for wptouch hack end ----->
    

    Please include this bug fix in future versions, thanks!

    • This topic was modified 5 years, 4 months ago by physixfan.
    • This topic was modified 5 years, 4 months ago by physixfan.
    • This topic was modified 5 years, 4 months ago by physixfan.
    • This topic was modified 5 years, 4 months ago by physixfan.
Viewing 1 replies (of 1 total)
  • Plugin Contributor dudo

    (@dudo)

    Hi, thank you for sharing this!

    I will test this and if everything is fine, will include in future versions, thank you so much!

Viewing 1 replies (of 1 total)
  • The topic ‘Conflict between YASR and WPTouch (Cannot read property ‘toFixed’ of undefined..’ is closed to new replies.