2011-10-24 116 views
1

我目前正在使用Siwapp的0.5版本,我试图在发票表的每一行显示支付按钮的弹出窗口。但我必须通过点击来完成。我有以下JS代码:如何在点击时显示弹出窗口?

jQuery(function($){ 

    $('table[data-type="invoices"] a.payments').popover({ 
    live: true, 
    placement: 'left', 
    offset: 5, 
    html: true, 
    content: function() { 
     return $(this).attr('class'); 
    }, 
    trigger: 'manual' 
    }).live('click', function(e){ 
    e.preventDefault(); 
    $(this).popover('show'); 
    }); 

}); 

表HTML是这个样子(见结尾的链接):

<table class="zebra-striped align-middle" data-type="invoices"> 
    <colgroup> 
    <col /> 
    <col /> 
    <col class="date" /> 
    <col class="date" /> 
    <col class="status" /> 
    <col class="currency" /> 
    <col class="currency" /> 
    <col class="payments" /> 
    </colgroup> 
    <thead> 
    <tr> 
     <th>{% trans %}Number{% endtrans %}</th> 
     <th>{% trans %}Customer{% endtrans %}</th> 
     <th>{% trans %}Date{% endtrans %}</th> 
     <th>{% trans %}Due Date{% endtrans %}</th> 
     <th>{% trans %}Status{% endtrans %}</th> 
     <th>{% trans %}Due{% endtrans %}</th> 
     <th>{% trans %}Total{% endtrans %}</th> 
     <th></th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr> 
     <td>ASET-22</td> 
     <td>Roxxon</td> 
     <td>5/28/11</td> 
     <td>9/16/11</td> 
     <td> 
     <span class="label important">{% trans %}overdue{% endtrans %}</span> 
     </td> 
     <td></td> 
     <td>$11,435.23</td> 
     <td> 
     <a href="{{ path('invoice_payments', { 'invoiceId': 4 }) }}" class="btn secondary icon clock payments" title="Payments">{% trans %}Payments{% endtrans %}</a> 
     </td> 
    </tr> 
    </tbody> 
</table> 

如果我删除了“手动”触发它的工作原理,但如果我设置它,它不。

任何人都知道如何做到这一点?谢谢!

回答

7

弹出窗口会自动处理你正在做的一些手动操作,它可能会导致一些奇怪的冲突。你可以自己添加你自己的点击处理程序,并且你正在包装看起来不需要的整个设置功能。尝试这样的:

$('table[data-type="invoices"] a.payments').popover({ 
    live: true, 
    placement: 'left', 
    offset: 5, 
    html: true, 
    content: function() { 
    return $(this).attr('class'); 
    }, 
    trigger: 'manual' 
}); 
相关问题