diff --git a/assets/js/frontend/single-product.js b/assets/js/frontend/single-product.js index 19d0f223d54..759fae2f087 100644 --- a/assets/js/frontend/single-product.js +++ b/assets/js/frontend/single-product.js @@ -28,22 +28,26 @@ jQuery(document).ready(function($) { // Star ratings for comments $('#rating').hide().before('
'); - $('p.stars a').live( 'click', function(){ - var $star = $(this); - $('#rating').val( $star.text() ); - $('p.stars a').removeClass('active'); - $star.addClass('active'); - return false; - }); + $('body') + .on( 'click', '#respond p.stars a', function(){ + var $star = $(this); + var $rating = $(this).closest('#respond').find('#rating'); - $('#review_form').on( 'click', '#submit', function(){ - var rating = $('#rating').val(); + $rating.val( $star.text() ); + $star.siblings('a').removeClass('active'); + $star.addClass('active'); - if ( $('#rating').size() > 0 && !rating && woocommerce_params.review_rating_required == 'yes' ) { - alert(woocommerce_params.i18n_required_rating_text); return false; - } - }); + }) + .on( 'click', '#respond #submit', function(){ + var $rating = $(this).closest('#respond').find('#rating'); + var rating = $rating.val(); + + if ( $rating.size() > 0 && ! rating && woocommerce_params.review_rating_required == 'yes' ) { + alert(woocommerce_params.i18n_required_rating_text); + return false; + } + }); // prevent double form submission $('form.cart').submit(function(){ diff --git a/assets/js/frontend/single-product.min.js b/assets/js/frontend/single-product.min.js index 5b17c717cf7..d86c544c5ab 100644 --- a/assets/js/frontend/single-product.min.js +++ b/assets/js/frontend/single-product.min.js @@ -1 +1 @@ -jQuery(document).ready(function(e){e(".woocommerce-tabs .panel").hide();e(".woocommerce-tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce-tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href")).show();t.parent().addClass("active");return!1});e(".woocommerce-tabs").each(function(){var t=window.location.hash;t.toLowerCase().indexOf("comment-")>=0?e("ul.tabs li.reviews_tab a",e(this)).click():e("ul.tabs li:first a",e(this)).click()});e("#rating").hide().before('');e("p.stars a").live("click",function(){var t=e(this);e("#rating").val(t.text());e("p.stars a").removeClass("active");t.addClass("active");return!1});e("#review_form").on("click","#submit",function(){var t=e("#rating").val();if(e("#rating").size()>0&&!t&&woocommerce_params.review_rating_required=="yes"){alert(woocommerce_params.i18n_required_rating_text);return!1}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})}); \ No newline at end of file +jQuery(document).ready(function(e){e(".woocommerce-tabs .panel").hide();e(".woocommerce-tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce-tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href")).show();t.parent().addClass("active");return!1});e(".woocommerce-tabs").each(function(){var t=window.location.hash;t.toLowerCase().indexOf("comment-")>=0?e("ul.tabs li.reviews_tab a",e(this)).click():e("ul.tabs li:first a",e(this)).click()});e("#rating").hide().before('');e("body").on("click","#respond p.stars a",function(){var t=e(this),n=e(this).closest("#respond").find("#rating");n.val(t.text());t.siblings("a").removeClass("active");t.addClass("active");return!1}).on("click","#respond #submit",function(){var t=e(this).closest("#respond").find("#rating"),n=t.val();if(t.size()>0&&!n&&woocommerce_params.review_rating_required=="yes"){alert(woocommerce_params.i18n_required_rating_text);return!1}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})}); \ No newline at end of file