【发布时间】:2016-08-12 16:11:24
【问题描述】:
这是我自己的js文件。
function hesap (hesapdiv, hesapmodal, hesapid){
this.hesapid = hesapid;
this.hesapdiv = hesapdiv;
this.hesapmodal = hesapmodal;
hesapdiv.on("click", "button", function() {
hesapmodal.modal("show");
});
hesapmodal.on("click", "button[hesapid]", function() {
var hesapid = $(this).attr('hesapid');
console.log(this.hesapid + "-" + hesapid + "-" + $(this).attr('hesapid'));
var isim = $(this).attr('isim');
hesapdiv.find("input").val(hesapid + " - " + isim);
hesapmodal.modal('hide');
});}
下面的代码,我可以在我所有的网页中使用。
var hesap1 = new hesap($("#hesapdiv"), $("#HesaplarModal"), 36);
$("#kasaislemikaydet").on('click', function(event) {
event.preventDefault(); // To prevent following the link (optional)
alert(hesap1.hesapid);)};
现在,当用户从模态中选择“hesap”时,获取属性值的函数是成功的。但它不会将值分配给对象的“hesapid”。所以从网页上我无法获得 hesapid 的新价值。例如,单击按钮以获取新选择的“hesapid”的值,始终提醒第一个值“36”。
【问题讨论】:
标签: javascript jquery oop