Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery not handling multiple changes to dom element
    primarykey
    data
    text
    <p>I have a table that I am making changes to using jQuery.</p> <p>I want to make 2 changes, the first to replace an element and then re-sort the table using tablesorter.</p> <pre><code>$("#sl" + myrec_id).replaceWith(result.html); $("#scenario_item_list").tablesorter({ sortList: current_scenareoSort }); </code></pre> <p>The issue is that if I do the table sort then the item is added to the table as a second row rather than replacing.</p> <p>Each line works OK independently, but not together.</p> <p>UPDATED : Here is the full code</p> <pre><code>$(".save_item_update" ).live("touchstart click",function(event) { event.preventDefault(); var mysc_id = $("#scenarioid").attr("class"); var myrec_id = $("#recordid").attr("class"); var loadtype = $("#edittype").attr("class"); var fr_description = $("#fr_description").val(); var fr_type = $("#fr_type").val(); var fr_paymentfrequency = $("#fr_paymentfrequency").val(); var fr_amount = $("#fr_amount").val(); var fr_payhowtype = $("#fr_payhowtype").val(); var fr_balance = $("#fr_balance").val(); var fr_asatdata = $("#fr_asatdata").val(); var fr_interestrate = $("#fr_interestrate").val(); var sl_differentdata = $("#sl_differentdata").val(); var sl_amount = $("#sl_amount").val(); var sl_paymentfrequency = $("#sl_paymentfrequency").val(); var fr_comment = $("#fr_comment").val(); $.post("/scenario/save_item_update", { loadtype : loadtype, item_id : myrec_id, sl_scenario_id : mysc_id, fr_description:fr_description, fr_paymentfrequency:fr_paymentfrequency, fr_amount:fr_amount, fr_payhowtype:fr_payhowtype, fr_balance:fr_balance, fr_asatdata:fr_asatdata, fr_interestrate:fr_interestrate, fr_type:fr_type, fr_comment:fr_comment }, function(result){ if (result.status == "NOT LOGGED IN" ) { NotLoggedIn(true); } else if (result.status == 'ERROR') { ReportError(result.errormessage,true) } else { if (loadtype == 'sl_remove') { $("#finance_item_list tbody").append(result.html); $("#sl" + myrec_id).remove(); $("#mthremain").html(result.monthremaining); $("#finance_item_list").tablesorter({ sortList: current_financeSort }); } else if (loadtype == 'fi_dodelete') { $("#fr" + myrec_id).remove(); } else if (loadtype == 'fi_use') { $("#scenario_item_list tbody").append(result.html); $("#mthremain").html(result.monthremaining); $('#fr' + myrec_id).remove(); $("#scenario_item_list").tablesorter({ sortList: current_scenareoSort }); closePopUp(); $("#popup_body").html(''); } else if (loadtype == 'fi_edit') { $("#fr" + myrec_id).replaceWith(result.html); $("#finance_item_list").tablesorter({ sortList: current_financeSort }); closePopUp(); $("#popup_body").html(''); } else if (loadtype == 'sl_edit') { $("#sl" + myrec_id).replaceWith(result.html); $("#mthremain").html(result.monthremaining); $("#scenario_item_list").tablesorter({ sortList: current_scenareoSort }); closePopUp(); $("#popup_body").html(''); } else if (loadtype == 'fi_insert') { $("#finance_item_list tbody").append(result.html); //$("#finance_item_list").tablesorter({ sortList: current_financeSort }); closePopUp(); $("#popup_body").html(''); } } },"json"); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload