0
votes

I am beginner in Orchard CMS and i need add voting functionality to content. I have installed Contib.Vote and Contrib.Review modules. After that i have added Review part to page content type. Also, i have executed recipe. At the first look everything is fine, but link for review refer to the same page with # symbol and nothing is happenning by clicking on it. It seems like module does not work or work incorrectly. Please help with my problem.

UPD. Hi devqon and thanx for your help. Your answer was really useful for me. According to your advice i was looking around javascript inside Review Part view file (Parts_Reviews.cshtml). Just for a test i changed its source code a little bit.

@using (Script.Foot())
{
    <script type="text/javascript">
    //<![CDATA[
    (function () {
        var numberOfReviewsToShowByDefault = 5;
        var $showAllReviewsLink = $('#showAllReviewsLink');
        var $deleteReviewConfirmationDialogDiv = $('#deleteReviewConfirmationDialogDiv');


            $deleteReviewConfirmationDialogDiv.dialog({ autoOpen: false, modal: true, resizable: false });
            $('#deleteReviewLink').click(function () {
                $('#reviewId').val($(this).attr("data-review-id"));
                ShowDeleteReviewDialog();
                return false;
            });
            $('#showReviewFormLink').click(function () {
                $('#createReviewLinkDiv').slideToggle('fast', function () { $('#reviewFormDiv').slideToggle('fast'); });
                return false;
            });
            $('#cancelCreateReviewLink').click(function () {
                $('#reviewFormDiv').slideToggle('fast', function() { $('#createReviewLinkDiv').slideToggle('fast'); });
                return false;
            });
            $('#deleteReviewForm').submit(function () {
                $('input[type=submit]', this).attr('disabled', 'disabled');
            });
            $('#cancelDeleteReviewButton').click(function () {
                CloseConfirmationDialogDiv();
                return false;
            });
            var rowCount = $('#reviewsList li').length;
            if (rowCount > numberOfReviewsToShowByDefault) {
                SetupToggle();
            }

            if (document.location.hash === '#Reviews') {
                var topPx = $('#reviews-heading').position().top;
                $('body,html').animate({ scrollTop: topPx }, 'slow');
            }

            if ($("#comment").length) {
                var characterCountUpdater = new CharacterCountUpdater($("#comment"), $("#commentCharactersLeft"));
                setInterval(function() { characterCountUpdater.UpdateCharacterCount(); }, 100);
                $("#comment").keypress(function() { characterCountUpdater.UpdateCharacterCount(); });

                if ($("#comment").val().length) {
                    $("#showReviewFormLink").trigger("click");
                }
            }
        
        function CharacterCountUpdater(commentBox, charactersLeftBox)
        {
            this.commentBox = commentBox;
            this.charactersLeftBox = charactersLeftBox;
            this.maxLength = commentBox.attr("maxlength");
            commentBox.removeAttr("maxlength");
            return this;
        }

Now form for review is displayed. The form looks good, submit button works, character counter works too. But i still can't apply my rating. Stars not react on clicking. That is why submit operation ends with error 'In order to submit a review, you must also submit a rating.'. Look like something inside Parts.Stars.NoAverage.cshtml does not work. Please, help me.

3
Would you mind sharing the whole problem and how you fixed it? For future stackoverflow searchers that can be handy - devqon
Doesn't look like there is any script that handles the rating by star stuff.. - devqon
Never mind, it is as you say in the Parts.Stars.NoAverage.cshtml. Are there any console errors? - devqon
Thank you so much! Console of Firefox tells: $(...).live is not a function. It refers to Contrib.Stars.js source code file. This function is not supported in jquery now and i replaced it by .on() function in all places api.jquery.com/on. Now module works fine. How can i share the solution with community? - Andrey Khramov

3 Answers

0
votes

According to the project's site it is a known issue: broken from version 1.7.2.

When looking at the code of the Parts_Reviews.cshtml it says the following on lines 20-24:

string showReviewUri = "#";
if (!Request.IsAuthenticated)
{
    showReviewUri = Url.Action("LogOn", "Account", new { area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl });
}

and on line 29:

<div id="createReviewLinkDiv"><span id="createReviewLinkSpan">@noReviewsYetText<a id="showReviewFormLink" href="@showReviewUri">@reviewLinkText</a></span></div>

Therefore, it was intended to let the anchor be # when the request is authenticated (you are logged on). This means it probably will be handled in JavaScript, which can be seen on lines 105-112:

$('#showReviewFormLink').click(function () {
    $('#createReviewLinkDiv').slideToggle('fast', function () { $('#reviewFormDiv').slideToggle('fast'); });
    return false;
});
$('#cancelCreateReviewLink').click(function () {
    $('#reviewFormDiv').slideToggle('fast', function() { $('#createReviewLinkDiv').slideToggle('fast'); });
    return false;
});

This piece of code should let you see the form to write a review, so something is going wrong there presumably. When there's something wrong in this jQuery code it probably gives an error in the console, so check out the browser's console when you click the 'Be the first to write a review' link.

This should get you further, if you don't know what to do please provide the error and I will try to dig more. I haven't downloaded the module so I don't have live feed.

0
votes

Console of Firefox tells: $(...).live is not a function. It refers to Contrib.Stars.js source code file. This function is not supported in jquery now and i replaced it by .on() function in all places api.jquery.com/on. Now module works fine.

0
votes

Check out my comment at the site below to see how I was was able to get it working again on Orchard 1.8.1:

Orchard Reviews Project Site

You basically just need to change 3 different lines in the Contrib.Stars.js file but I would recommend copying the .js file along with the Review module's different views to a custom theme directory, in order to override everything and force the Reviews module to use your edited .js file:

On line 12 & 13:

Change this:

$(".stars-clear").live(
    "click",

To this:

$("body").on(
    "click", ".stars-clear",

On line 44 & 45:

Change this:

.live(
    "mouseenter",

To this:

.mouseenter(

On line 48 & 49:

Change this:

.live(
    "mouseleave",

To this:

.mouseleave(