Conflict between YASR and WPTouch (Cannot read property ‘toFixed’ of undefined..
-
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!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Conflict between YASR and WPTouch (Cannot read property ‘toFixed’ of undefined..’ is closed to new replies.