如何查看点击哪个链接来调用jQuery弹出窗口?这里是data-card-id,我必须将其传递给JavaScript函数,其中使用此值调用php脚本然后创建弹出窗口的内容
我调用弹出窗口的代码:
<div class="cardbutton">
<a href="#cardpopup" data-card-id="1" data-rel="popup" class="ui-btn" data-position-to="window">Anleitung starten</a>
</div>
<div class="cardbutton">
<a href="#cardpopup" data-card-id="2" data-rel="popup" class="ui-btn" data-position-to="window">Anleitung starten</a>
</div>
名为Popup:
<div data-role="popup" id="cardpopup" data-dismissible="false" data-transition="slideup" class="cardpopup">
<div data-role="header">
<h1>cardpopupTemplate</h1>
</div>
<div data-role="main" class="ui-content" id="popupcardOuterDiv">
<!-- hier folgt der generierte HTML Code für die einzelnen Schritte in der Anleitung -->
<!-- here is the popupCode generated in JavaScript -->
</div>
</div>
myJavaScript:
$('#cardpopup').on({
popupbeforeposition: function(){
console.log($(this).data("card-id")); // undefined :(
var h = $(document).height()-50;
var w = $(document).width()-50;
$("#cardpopup").css({
"height": h,
"width": w
});
createPopupManual(1, function(){ // here i have to pass the data-card-id value of the link
var h = $("#popuppage1").height();
var w = $("#popuppage1").width();
$(".popupTopLeft").css({
"height": h*0.8,
"width": w*0.3
});
$(".popupTopRight").css({
"height": h*0.8,
"width": w*0.7,
"left": (w*0.3)+16
});
$(".popupBottomLeft").css({
"height": h*0.2,
"width": w*0.3,
"top": (h*0.8)+58
});
$(".popupBottomRight").css({
"height": h*0.2,
"width": w*0.7,
"top": (h*0.8)+58,
"left": (w*0.3)+16
});
});
},
popupafterclose: function(){
$('#cardpopup').slideDown();
}
});