Javascript 将事件绑定到jQuery模式弹出窗口中动态添加的元素
我正在使用。我在弹出窗口中显示了许多文本框和按钮。有一个按钮,Javascript 将事件绑定到jQuery模式弹出窗口中动态添加的元素,javascript,jquery,html,asp.net,jquery-ui,Javascript,Jquery,Html,Asp.net,Jquery Ui,我正在使用。我在弹出窗口中显示了许多文本框和按钮。有一个按钮,btnaddlot,我想在其中添加一个单击事件,但我无法这样做 var varLot = '<b>Lot Title: </b> <input type="text" id="txtlottitle" style="width:500px;" value="Lot Title" /> <textarea id="lotstextarea"></textarea> <in
btnaddlot
,我想在其中添加一个单击事件,但我无法这样做
var varLot = '<b>Lot Title: </b> <input type="text" id="txtlottitle" style="width:500px;" value="Lot Title" /> <textarea id="lotstextarea"></textarea> <input type="submit" value="ADD" id="btnAddLot" class="bluebutton" style="float:right;"/> <br /> <div id="lottypes"> <table> <tr> <td style="width:width: 80px;"><b>Lot Types: </b></td><td> <table> <tr><td><table><tr><td><input id="rdoitemlot" name="lottype" type="radio" value="Item Lot" /></td><td>Item Lot - Bid at Item level, compete at Lot level(collect item pricing during bidding.)</td></tr></table> </td></tr> <tr><td><table><tr><td><input id="rdobasketlot" name="lottype" type="radio" value="Basket"/></td><td>Basket - Bid at Lot level, compete Lot level(collect item pricing post bidding.)</td></tr></table> </td></tr> <tr><td><table><tr><td><input id="rdobasketwithnoitem" name="lottype" type="radio" value="Basket with No Items" /></td><td> Basket with No Items - Bid at Lot level, compete Lot level(Do not collect item pricing.)</td></tr></table> </td></tr> </table></td> </tr> </table> </div> <hr /> <table> <tr> <td>Improve Bid By: </td><td><span id="lblimprovebidsby"></span></td> </tr> <tr> <td><span id="lblbiddecrement">Bid Decrement</span></td><td><input type="number" id="txtbiddecrement" /></td> </tr> <tr> <td><span >Protect the lead bid with front buffer of : </span></td><td><input type="number" id="txtfrontbuffer" /></td> </tr> <tr> <td><span >Protect the lead bid with back buffer of : </span></td><td><input type="number" id="txtbackbuffer" /></td> </tr> <tr> <td><span >Can participants submit tie bids : </span></td><td><span id="lbltiebids"></span></td> </tr> </table>'
var section = $(this);
$(this).toggleClass("expand");
$(function () {
$("#dialog").dialog(
{ width: 800 },
{ height: 600 },
{ modal: true },
{
open: function (event, ui) {
$("#dialog").html(varLot);
$("textarea").jqte();
//$("#dialog").append($(section).html());
},
buttons: {
"OK": function () {
$(this).dialog("close");
}
}
}
);
只需将html添加为常规代码,就可以立即设置onclick。如果需要,首先将弹出窗口设置为隐藏
$('btnAddLot')。单击(函数(e){
警惕(‘嘿’);
e、 预防默认值();
});
$(“#对话框”)。对话框({
宽度:800
}, {
身高:600
}, {
莫代尔:对
}, {
打开:功能(事件、用户界面){
$(“#对话框”).show();
$(“#dialog”).html(varLot);
$(“textarea”).jqte();
//$(“#dialog”).append($(section.html());
},
按钮:{
“OK”:函数(){
$(此).dialog(“关闭”);
}
}
});代码>
地段名称:
地段类型:
项目批次-在项目级别进行投标,在批次级别进行竞争(在投标期间收集项目定价。)
篮子-在批次级别、竞争批次级别进行投标(在投标后收集项目定价。)
没有物品的篮子-在批次级别投标,竞争批次级别(不收集物品定价。)
通过以下方式改进投标:
投标减量
用以下前缓冲器保护主投标书:
用以下缓冲区保护主要投标:
参与者能否提交tie投标:
只需将html添加为常规代码,就可以立即设置onclick。如果需要,首先将弹出窗口设置为隐藏
$('btnAddLot')。单击(函数(e){
警惕(‘嘿’);
e、 预防默认值();
});
$(“#对话框”)。对话框({
宽度:800
}, {
身高:600
}, {
莫代尔:对
}, {
打开:功能(事件、用户界面){
$(“#对话框”).show();
$(“#dialog”).html(varLot);
$(“textarea”).jqte();
//$(“#dialog”).append($(section.html());
},
按钮:{
“OK”:函数(){
$(此).dialog(“关闭”);
}
}
});代码>
地段名称:
地段类型:
项目批次-在项目级别进行投标,在批次级别进行竞争(在投标期间收集项目定价。)
篮子-在批次级别、竞争批次级别进行投标(在投标后收集项目定价。)
没有物品的篮子-在批次级别投标,竞争批次级别(不收集物品定价。)
通过以下方式改进投标:
投标减量
用以下前缓冲器保护主投标书:
用以下缓冲区保护主要投标:
参赛者能否提交tie b
$('#pricingdiv').on('click', '#btnAddLot', function (e) {
alert('hey');
e.preventDefault();
});
$(function () {
var varLot = '<b>Lot Title: </b> <input type="text" id="txtlottitle" style="width:500px;" value="Lot Title" /> <textarea id="lotstextarea"></textarea> <input type="submit" value="ADD" id="btnAddLot" class="bluebutton" style="float:right;"/> <br /> <div id="lottypes"> <table> <tr> <td style="width: 80px;"><b>Lot Types: </b></td><td> <table> <tr><td><table><tr><td><input id="rdoitemlot" name="lottype" type="radio" value="Item Lot" /></td><td>Item Lot - Bid at Item level, compete at Lot level(collect item pricing during bidding.)</td></tr></table> </td></tr> <tr><td><table><tr><td><input id="rdobasketlot" name="lottype" type="radio" value="Basket"/></td><td>Basket - Bid at Lot level, compete Lot level(collect item pricing post bidding.)</td></tr></table> </td></tr> <tr><td><table><tr><td><input id="rdobasketwithnoitem" name="lottype" type="radio" value="Basket with No Items" /></td><td> Basket with No Items - Bid at Lot level, compete Lot level(Do not collect item pricing.)</td></tr></table> </td></tr> </table></td> </tr> </table> </div> <hr /> <table> <tr> <td>Improve Bid By: </td><td><span id="lblimprovebidsby"></span></td> </tr> <tr> <td><span id="lblbiddecrement">Bid Decrement</span></td><td><input type="number" id="txtbiddecrement" /></td> </tr> <tr> <td><span >Protect the lead bid with front buffer of : </span></td><td><input type="number" id="txtfrontbuffer" /></td> </tr> <tr> <td><span >Protect the lead bid with back buffer of : </span></td><td><input type="number" id="txtbackbuffer" /></td> </tr> <tr> <td><span >Can participants submit tie bids : </span></td><td><span id="lbltiebids"></span></td> </tr> </table>'
$("div#dialog").on("click","#btnAddLot",function () {
alert('hey');
});
$("#dialog").html(varLot).hide().dialog({
//you might put your options here
});
})