[英]How to make a conditional show and hide modal to my on click function
I have problem to my show and hide modal,So when i click the input number inside of table data the why the modal still showing, I have a function which when i change the value of input number , the modal will hide. 我有显示和隐藏模态的问题,所以当我单击表数据内的输入数字时为何仍显示模态,我有一个功能,当我更改输入数字的值时,模态将隐藏。
So here below, I will show you the codes I have, 因此,在下面,我将向您展示我拥有的代码,
First I have append function to append all data inside of table 首先我有附加功能来附加表内的所有数据
$('#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>");
Now Second when i click each table row, modal will show, 现在,当我单击每个表格行时,第二个将显示模式,
$('#edit_chainingBuild').on('click','tr.clickable-row',function(e){
$('table#edit_chainingBuild tr').removeClass('selected');
$(this).addClass('selected');
var find_each_id_will_update = $(this).find('.data-attribute-chain-id').attr('data-attribute-chain-id');
$('.id_to_update_chain').val(find_each_id_will_update);
$('#EditcondimentsBuilderModal').modal('show');
});
The output of that two is this, 这两个的输出是这样的,
Now here in my second scenario, When i change the value of Input number quantity, I want to stop the modal to open which the id is this. 现在在第二种情况下,当我更改“输入数字数量”的值时,我想停止该id为的模态打开。
$('#EditcondimentsBuilderModal').modal();
My Codes for changing the quantity is this. 我的更改数量的密码是这样的。
$(document).on('change', '.changeQuantity', function() {
// Does some stuff and logs the event to the console
alert($(this).val());
$("#EditcondimentsBuilderModal").modal('hide');
});
The output of changing quantity is working, The question is I want to have condition if i change the value of quantity modal will not show, 变化量的输出正常工作,问题是如果我更改数量模态的值将不显示条件,
Your hiding code seems ok, so it should be hiding #EditcondimentsBuilderModal
. 您的隐藏代码看起来还不错,因此应该隐藏#EditcondimentsBuilderModal
。 But then there's your $('#edit_chainingBuild').on('click','tr.clickable-row', ...
handler that attempts to show it again on click. So it can easily result in a weird and confusing behavior, if you for example focus an input field with the mouse, before changing it (effectively triggering both handlers that is - open and close). 但是接着是您的$('#edit_chainingBuild').on('click','tr.clickable-row', ...
处理程序试图在单击时再次显示它,因此很容易导致奇怪和混乱的行为,例如,如果您用鼠标将输入字段聚焦,则在更改之前(有效地触发打开和关闭的两个处理程序)。
Consider altering the logic for either of the handlers, at least temporarily - to confirm the case. 考虑至少暂时更改两个处理程序中任何一个的逻辑,以确认情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.