[英]How to prevent appending multiple times in the table, Once It forcing to double click multiple times the table row using Jquery?
我有模塊將響應結果附加到另一個表。 期待我在我的模塊中找到了解決方案。 但是我發現了問題,我會給你們解決方案問題所在。
第一種情況 :用戶將選擇他想單擊的調味品,向前看。 用戶1選擇第二個表行,即調味品* LG FRIES 。
第二種情況 :在第一種情況下,用戶選擇* LG FRIES ,如您所見,模態將打開,響應結果將附加到表B中。
第三種情況 :第一種和第二種情況看起來不錯,但是在這里,我將向您展示,一旦我強制雙擊* LG FRIES的表行,追加將如何在表中相乘。
所以現在我讓您展示我的代碼。
這是我獲取單擊表行的結果的功能,然后結果將附加到表B。
$('table#noun_chaining_order').on('click','tr.editCondiments',function(e){
var allow_to_open_condiments_conditional = $(this).closest("tr").find(".allow_to_open_condiments_conditional").text();
if(allow_to_open_condiments_conditional == 'Yes') {
$('.conditional_table_hidden_noun').hide();
$('.conditional_table_hidden_condiments').show();
$('table#noun_chaining_order tr').removeClass('selected');
$(this).addClass('selected');
var find_each_id_condiments = $(this).find('td.condi_section_id').text();
$("table#customer_table_update_chain_order tbody").html('');
$('#customer_modal_update_chain_order').modal('show');
$.ajax({
url:'/get_each_id_section_condiments',
type:'get',
data:{find_each_id_condiments:find_each_id_condiments},
success:function(response){
var get_each_section = response[0].condiments_table;
$.each(get_each_section, function (index, el) {
var stringify = jQuery.parseJSON(JSON.stringify(el));
var cat_condi_screen_name = stringify['cat_condi_screen_name'];
var cat_condi_price = stringify['cat_condi_price'];
var cat_condi_image = stringify['cat_condi_image'];
var image = '<img src=/storage/' + cat_condi_image + ' class="responsive-img" style="width:100px;">';
// $('#edit_chainingBuild').append("<tr class='clickable-row'><td>" + Qty + "</td><td class='clickable-row-condiments'>" + Condiments + "</td><td>" + Price + "</td><td style='display:none;' data-attribute-chain-id="+menu_builder_details_id +" class='data-attribute-chain-id'>"+menu_builder_details_id+"</td></tr>");
$('table#customer_table_update_chain_order tbody').append("<tr class='edit_condimentsClicked' style='font-size:14px; border:none;'><td class='edit_condimentsScreenNameClicked'>" + cat_condi_screen_name + "</td><td class='edit_condimentsScreenPriced'>" + cat_condi_price + "</td><td>"+image+"</td></tr>");
});
},
error:function(response){
console.log(response);
}
});
}
else
{
}
});
因此,問題將是,一旦我強制雙擊表格行,如何停止多次追加?
我在這里看到簡單的解決方案。
無論如何,請檢查何時執行ajax請求? 點擊后?
您是否嘗試過使用斷點調試代碼? 或控制台?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.