Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:59+00:00 2026-05-27T13:07:59+00:00

I have a page with the below structure (HTML content shortened for readability), where

  • 0

I have a page with the below structure (HTML content shortened for readability), where the order of the ‘pictureinthread’ divs in the DOM when the page is rendered is based on the number of votes in the ‘voteamount’ child div (which is actually two levels down given the picturemeta div). The user has the ability to dynamically upvote a given image (via Ajax) which increases its count (the value in ‘voteamount’). I would like, if the position of div should change based on the vote, for it to dynamically animate and assume its new proper position. I already have the ajax working properly and the number in ‘voteamount’ updating, but my javascript/Jquery experience is not enough to go further, which is to inspect all the other values in the ‘voteamount’ for the other ‘pictureinthread’s and do a nice animation if the ‘pictureinthread’ should move.

Note I realize that currently it could only move one spot, but I would like the ability for it to move anywhere within the list of ‘pictureinthread’ based on the returned value from the ajax call, as the voting logic will get more complicated.

I am using Grails with the JQuery plugin, and currently the Ajax looks like this for each div as per the below, you can see where I need the help (I’m assuming onComplete is the best point given http://grails.org/doc/latest/ref/Tags/remoteLink.html)

<g:remoteLink onComplete="HELP ME HERE!" controller="voting" action="upvote" update="upvotes${pictureInThread.id}" id="${pictureInThread.id}">

And my HTML

    <div class="pictureinthread" id="..">
        <img src="..." id="..." class="..."/>

        <div class="picturemeta">
            <a href="..ajax call rendered with the g:remotelink..."><img class="thumbsup" src="..."/> <div class="voteamount" id='upvotes+unique...'>3</div></a>     
        </div>
    </div>


    <div class="pictureinthread" id="...">
        ..many more like the above..
    </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:08:00+00:00Added an answer on May 27, 2026 at 1:08 pm

    Alternatively, since it’s the UX/animation that is important, here’s another method:

    http://jsfiddle.net/andromedado/jhYd7/

    The basic idea is that the function updatePos accepts a jQuery wrapped <div class="pictureinthread">, and it will animate it into the correct position relative to its immediate siblings. In the jsFiddle I have the event triggered on click, but in your model you would trigger it on ajax update.

    CSS

    .rel {postion:relative;}
    

    JS

    function getVN($div){
        return parseInt($div.find('.voteamount').text(),10);
    }
    function sendDown($div){
        //Prettily Animated Swap of this div with it's next sibling
        var h = $div.height(),
            d1 = false,
            d2 = false,
            c = $div.add($div.next()).addClass('rel');
        $div.animate({top:h},1000,'linear',function(){
            d1 = true;
            if (d1 && d2) {
                $div.next().after($div);
                c.removeClass('rel').attr('style','');
                updatePos($div);
            }
        });
        $div.next().animate({top:(-1 * h)},1000,'linear',function(){
            d2 = true;
            if (d1 && d2) {
                $div.next().after($div);
                c.removeClass('rel').attr('style','');
                updatePos($div);
            }
        });
    }
    function sendUp($div){
        //Prettily Animated Swap of this div with it's previous sibling
        var h = $div.prev().height(),
            d1 = false,
            d2 = false,
            c = $div.add($div.prev()).addClass('rel');
        $div.animate({top:(-1 * h)},1000,'linear',function(){
            d1 = true;
            if (d1 && d2) {
                $div.after($div.prev());
                c.removeClass('rel').attr('style','');
                updatePos($div);
            }
        });
        $div.prev().animate({top:h},1000,'linear',function(){
            d2 = true;
            if (d1 && d2) {
                $div.after($div.prev());
                c.removeClass('rel').attr('style','');
                updatePos($div);
            }
        });
    }
    function updatePos($div){
        var mV = getVN($div), pV, nV;
        if ($div.prev('.pictureinthread').length) {
            pV = getVN($div.prev('.pictureinthread'));
            if (pV < mV) return sendUp($div);
        }
        if ($div.next('.pictureinthread').length) {
            nV = getVN($div.next('.pictureinthread'));
            if (nV > mV) return sendDown($div);
        }
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have menu structure like below <ul class=menu_bg id=menu-main-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page menu-item-653
i have ul li structure like below <ul class=lft_mnu id=menu-main-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page
I have menu structure like below, <ul class=sub-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page menu-item-34 id=menu-item-34><a
i have menu structure like below, <ul> <li class=menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-1406
I have a page (below) that has a datagrid that lists item's returned from
I have a page with 5 buttons on top. I want the area below
I have three tables tag , page , pagetag With the data below page
I have uploaded a page with the code below to my joomla root directory.
I have a search page with the following scenarios listed below. I was told
in my application i have the playvideo page where video will play, below that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.