0

我正在尝试使用jQuerytools 覆盖进行确认对话。我对调用叠加层的“onclick”函数有疑问。

HTML

<!-- list element -->
<ul>
    <li id="item1">
         <div class="listName">myListElement-1</div>
         <div class="listCtrlr"><span onclick="delItem(1, 'myListElement-1')" rel="#deldlg">delete</span></div>
    </li>
    <li id="item2">
         <div class="listName">myListElement-2</div>
         <div class="listCtrlr"><span onclick="delItem(2, 'myListElement-2')" rel="#deldlg">delete</span></div>
    </li>
    <li id="item3">
         <div class="listName">myListElement-3</div>
         <div class="listCtrlr"><span onclick="delItem(3, 'myListElement-3')" rel="#deldlg">delete</span></div>
    </li>
</ul>



<!-- overlay dialogue -->
<div id="deldlg" class="modd">
    <h5>Confirmation - Delete Campaign</h5>
    <div class="ctn">
        <p id="dq">Are you sure you want to permanently delete this data?</p>
        <p id="di"></p>
        <input type="button" value="Yes" id="delsubmit" class="brButton s grdRed">
        <input type="button" value="No" class="brButton s close">
    </div>
</div>

JavaScript

function delItem(iid, iname) {
    var trigger = this;
    trigger.overlay({
                    fixed: false,
                    closeOnClick: false,
                    mask: {color:'#660000', loadSpeed:100, opacity:0.9},
                    onBeforeLoad:function() {
                                    jQuery('#di').html(iname);
                                    jQuery('#delsubmit').attr('onclick', 'del_camp('+iid+')');
                                }
                });
}

当我使用上面的脚本时,它返回' trigger.overlay is not a function '。有人可以帮我解决这个问题吗?

我期望得到以下结果(假设我要删除 element-2)

Confirmation - Delete Campaign
-------------------------------------------------------------
Are you sure you want to permanently delete this data?

    myListElement-2

[ Yes ]     [ No ]
4

2 回答 2

0

Ok so I now know what the issue you are having is. Ok so you need to either set an id explicitly for whatever HTML element you are using as the overlay. then use it like this $("#findme").overlay({..}); The this object you were referring to was the scope of the function you were in, not a DOM element. At least from what I can tell of your code.

于 2013-05-03T11:14:58.913 回答
0

我认为它应该是 $(this).overlay(...) 代替,因为这不是一个 jquery 对象,而是一个简单的 dom 对象,因此无法访问 jquery 函数/插件

于 2013-05-03T10:15:10.053 回答