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 8265601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:51:48+00:00 2026-06-08T04:51:48+00:00

Lets say I may (but also may not) have an element with class order

  • 0

Lets say I may (but also may not) have an element with class order in my DOM.
It maybe create on page load but also, after successful ajax request. My question is, how can I add some live event, that will append something to my element based on it class?

Flow would be like this:

1.Opening page, jQuery searchs for elements with class order, if found, appends something to them (for this question lets say its text "text string"
2.I do an ajax request
3.After ajax request jQuery searchs again for class order and append if found

There is one condition, I DON’T want to trigger any function searching for elements after ajax request, I’d prefere some magic trick with .live() function, if it is possible of course.

EDIT Exact problem

What I was really trying to achive, is appending an img to certain class within newly loaded DOM.

From the beginning:

  1. I tried to implementing sortable/paginable table with displaytag and ajax.

  2. Then adding (also Ajax) search list filtering.

  3. After table is reloaded with Ajax, append images (up or down icon depending on sorting type)

See my answer for results

  • 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-06-08T04:51:49+00:00Added an answer on June 8, 2026 at 4:51 am

    Firstly, to implement ajax sorting / pagination I used Jquery DisplayTag Ajax pluging, using it is simple, just surround piece of code with div and run displayTagAjax() function on it.

    But then, I also wanted Ajaxable table filtering, that was tricky. First step was to create a separate jsp page with only display tag in it:

    Table.jsp

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@taglib uri="http://displaytag.sf.net" prefix="display" %>
    <display:table class="noSelect" id="modelsList" name="${modelsList}" pagesize="33" cellspacing="0"
               cellpadding="10" requestURI="">
    //
    //Columns here
    //
    </display:table>
    

    Then including this page in MainPage:

    Main.jsp

    <select id="searchbox-model-type>
    <!-- options here -->
    </select>
    <select id="searchbox-domain>
    <!-- options here -->
    </select>
    <!-- some more code -->
    <div id="model-list">
        <jsp:include page="Table.jsp"/>
    </div>
    

    After this steps, we need to fill up our table, so we need a Controller which will change our jsp page to plain html (with static, not ajaxable links yet):

    MyController

    @RequestMapping(value = "/ModelListTable/modelTypeId/{modelTypeId}/domain/{domainId}")
    public String getTable( Model model, @PathVariable Long modelTypeId, @PathVariable Integer domainId )
    {
        if ( modelTypeId != -1 && domainId != -1 )
        {
            model.addAttribute( "modelsList", modelManager.getModelList( modelTypeId, domainId ) );
        } else if ( modelTypeId != -1 )
        {
            model.addAttribute( "modelsList", modelManager.getModelList( modelTypeId ) );
        } else if ( domainId != -1 )
        {
            model.addAttribute( "modelsList", modelManager.getModelList( domainId ) );
        } else
        {
            model.addAttribute( "modelsList", modelManager.getModelList() );
        }
        return "Table";
    }
    

    I dont know if it is good piece of code I wrote, but you’ll get an idea, basically I’m making select from DB based on the values passed by select, -1 stands for no selected. Next step was to implement proper function in js file, which will make Ajax GET from my server:

    jQuery( function ()
    {
    jQuery.noConflict();
    
    loadTable();
    });
    
    function loadTable()
    {
        var domainId = jQuery( "#searchbox-domain option:selected" ).val();
        var modelTypeId = jQuery( "#searchbox-model-type option:selected" ).val();
        var url = "/Models/ModelListTable/modelTypeId/" + modelTypeId + "/domain/" + domainId;
        jQuery.ajax( url, {
            type:"GET",
            responseType:"text/html"
        } ).done( function ( data )
            {
                jQuery( "#model-list" ).html( data );
                jQuery( "#model-list" ).displayTagAjax( url );
            } );
    }
    

    Then I had to change displayTagAjax function, I append the url which is equal to Controller mapping URI, so we will always get filtered list when sorting/chaning page:

    $.fn.displayTagAjax = function ( pageUrl )
    {
    //omitted some code
      $.each( links, function ()
        {
        var url = pageUrl + $( this ).attr( "href" );
    //rest of the code
    

    Finally I appended my images to newly created elements in ajax call, also in this plugin 🙂 :

    jQuery.ajax(
        {
           url:url,
           success:function ( data )
           {
             $( this ).html( data );
             $( this ).find( '.order1' ).append( upIcon );
             $( this ).find( '.order2' ).append( downIcon );
             $( this ).displayTagAjax( pageUrl );
           },
           context:ctx
         } );
    

    And thats it, full Ajaxable display tag table, with dynamic filtering results and fancy icons for ordering 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a class A that is fairly simple like this -
Lets say you have a site where users may open chat rooms. Once a
I'm loading my javascript files using Modernizr.load() . Now lets say each page needs
Let's say i have a sql datetime of '1 May 2009' or '12 May
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
Lets say I have five tables named table1, table2 ... table5. I have already
Lets Say i have a table like this WEB_LIST_TABLE KEY Value ---------------------------------------- 134 google.com
Lets say i have at least two lua script files. test1.lua test2.lua both define
Lets say if I have a vector V, which has 10 elements. If I
Lets say I have image1 as Play Icon.png and image2 as pause.png . I

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.