search

Home  >  Q&A  >  body text

javascript - Add alert to bootstrap popup layer

bootstrap Add alert on the pop-up layer and cancel it after opening the modal. After opening the modal a second time and triggering the alert event, it will alert twice!

$("#" + data[i].id).on('click', function () {
                    var that = this;
                    $("#uploadmodal").modal('show');
                    $("#submit").on('click', function () {
                        var val = $('#sykmmc option:selected').text();
                        var opV = $('#sykmmc option:selected').val()
                        if(opV=="10086"){
                            alert('您还未选择科目!');
                            return false;
                        }
                        $(that).parent().find("span").text(val)
                        if($(that).text()=="匹配"){
                            $(that).text("修改")
                        }
                        if($(that).parent().parent().find("td").eq(4).text()=="未匹配")             {
                            $(that).parent().parent().find("td").eq(4).text("已匹配")
                        }
                        $("#uploadmodal").modal('hide');
                    })
                }

Every time the modal is canceled and the modal is triggered again after it is opened again, there will be one more alert than before.

天蓬老师天蓬老师2796 days ago541

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-19 10:25:55

    1 handful$("#submit").on('click',function(){}) 改成$("#submit").unbind('click').bind('click',function(){})Try

    2. You can also put $("#submit") after $("#" + data[i].id).on('click',function(){});. The reason is that you have registered multiple times.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-19 10:25:55

    Didn’t I say that it is not recommended to pop up multi-layered pop-up windows? Our product manager said that this is not a good user experience...

    reply
    0
  • Cancelreply