ThemeForest

Jquery Help! Please?

204 posts Bold WordPress Theme Development
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • Europe
  • Referred between 200 and 499 users
srhnbr says

Ok, I’m pulling my hair here with my Jquery code and I would appreciate someone’s help.

I already searched in Google but I can’t find anything related to the problem I have so if you have a resource link somewhere or if you know something I can try let me know.

Here’s what I’m trying to do:

the link

Hover the Reviews Tab to open the reviews. Click on the pagination to get to the second review page.

Firefox and Safari are fine. IE and Opera not!

I can confirm I am getting the right link to load. I can add js alerts on the click event if that helps.

Please, someone help!

2 years ago
2524 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Attended a Community Meetup
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Forum Moderator
  • Author had a Free File of the Month
  • Blog Editor
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 50 and 99 items
  • United States
  • Referred between 10 and 49 users
JeffreyWay says

Hey Sarah. Got your email. So sorry, but I’m literally walking out the door for the weekend (mini-vacation). I’m sure one of the awesome authors here can help, but if not, I’d be happy to take a look on Monday. :)

2 years ago
JeffreyWay is a moderator
204 posts Bold WordPress Theme Development
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • Europe
  • Referred between 200 and 499 users
srhnbr says
Hey Sarah. Got your email. So sorry, but I’m literally walking out the door for the weekend (mini-vacation). I’m sure one of the awesome authors here can help, but if not, I’d be happy to take a look on Monday. :)

Have a nice weekend then Jeffrey :)

Hope someone replies

2 years ago
61 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • United States
Mike343 says
Hey Sarah. Got your email. So sorry, but I’m literally walking out the door for the weekend (mini-vacation). I’m sure one of the awesome authors here can help, but if not, I’d be happy to take a look on Monday. :)

Have a nice weekend then Jeffrey :)

Hope someone replies

Can you show me the code you have so far?

Usually you can use a function like this when one of the pagination links is clicked it will call page that will load the comments.

Javascript

$(document).ready(function () {
    $("a.pagination").live("click", function (event) {
        var page = $(this).attr("href");
        var result = value.substring(page.indexOf('#') + 1);

        $.post("comments.php", { page: result }, function(data) {
            $("#comments").html(data);
        );

        return false;
    });
});

HTML

<a href="#1" class="pagination">2</a>
<a href="#2" class="pagination">2</a>

btw is this a magneto theme?

2 years ago
204 posts Bold WordPress Theme Development
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • Europe
  • Referred between 200 and 499 users
srhnbr says

This is the comment navigation in Wordpress so the html code is this:

<div class="comment_pagination">
    <span class="page-numbers current">1</span>
               <a href="http://thejewelryshop.sarah-neuber.de/some-category/prod3/comment-page-2#comments" class="page-numbers">2</a>
             <a href="http://thejewelryshop.sarah-neuber.de/some-category/prod3/comment-page-2#comments" class="next page-numbers">Next ยป</a> 
</div>

the jquery

var comments_wrap = $('#comments_warp');

    comments_wrap.click(function(event){
        var tgt = $(event.target);

        if (tgt.is('a.page-numbers')) {

            // let the user know that something is about to load 
            var ajax_load = "<img class="loadingImg" src="http://\"+ document.URL.split(\"/\")[2] + \"/wp-content/themes/TheJewelryShop/images/ajax-loader.gif" alt="loading..." />";

            // get the page specified in the trigger and a specific element from inside it 
            var Link = tgt.attr('href');

            //separate the # to get the class
            var Id = Link.split("#")[1];

            //put it together
            var toLoad = Link +' #' + Id;

            // load it! 
            comments_wrap.html(ajax_load).load(toLoad); 
            return false;

        }

    });
2 years ago
659 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • United States
  • Referred between 10 and 49 users
luckykind says

Maybe you did something… or maybe I’m missing something… but it seems the pagination is working fine for me in both Opera 10.53 & IE7 & IE8 … hover over review -> click link #2 -> review appears in all…

2 years ago
61 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 1 and 9 items
  • United States
Mike343 says
Maybe you did something… or maybe I’m missing something… but it seems the pagination is working fine for me in both Opera 10.53 & IE7 & IE8 … hover over review -> click link #2 -> review appears in all…

Yes, seems it is working now before I could reply :)

I would like to know what the problem was though. I was going to suggest this.

note: untested.

$("#comments_warp a[class~=page-numbers]").live("click", function (event) {
    var element = $(this);
    var page = element.attr("href");
        var result = value.substring(page.indexOf('#') - 1);

        $.post(element.attr("href"), { page: result }, function(data) {
            $("#comments_warp").html(data);
        );
});
2 years ago
204 posts Bold WordPress Theme Development
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • Europe
  • Referred between 200 and 499 users
srhnbr says

Yes it’s fixed!!

it was a stupid mistake really but I did not realize it till now.

Wordpress apends the #comments to the end of the anchor href so the fix was to remove it.

Here’s the working code:

var comments_wrap = $('#comments_warp');

    comments_wrap.click(function(event){
        var tgt = $(event.target);

        if (tgt.is('a.page-numbers')) {

            // let the user know that something is about to load 
            var ajax_load = "<img class="loadingImg" src="http://\"+ document.URL.split(\"/\")[2] + \"/wp-content/themes/TheJewelryShop/images/ajax-loader.gif" alt="loading..." />";

            // get the page specified in the trigger and a specific element from inside it 
            var Link = tgt.attr('href');

            //separate the # to get the class
            var urlParts     = Link.split("#");            
            var baseUrl        = urlParts[0];
            var Id         = urlParts[1];

            //put it together
            var toLoad         = baseUrl +' #' + Id;

            // ...and load it! 
            comments_wrap.html(ajax_load).load(toLoad); 
            return false;
        }
    });
this did the trick
//separate the # to get the class
var urlParts     = Link.split("#");            
var baseUrl        = urlParts[0];
var Id         = urlParts[1];

I guess I should be using the .live, the code is so much less but I am so tired now I better stop now that things work before I mess more things up, he, he

2 years ago
by
by
by
by
by