jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery-mobile – 如何在淘汰渲染完成后引发事件?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这个 jquery移动表正在进行淘汰.

<table data-role="table" id="report-table" class="ui-body-a ui-shadow ui-responsive table-Stripe"
    data-column-btn-theme="a" data-column-btn-text="Spalten..." data-column-popup-theme="a" data-mode="columntoggle"">
    <thead>
        <tr data-bind="foreach: columns">
            <th data-bind="text: $data.Caption,attr: { 'data-priority': 1 + Math.floor($index() / 4) }"></th>
        </tr>
    </thead>
    <tbody data-bind="foreach: { data: rows,afterRender: tableRowAfterRender }">
        <tr data-bind="foreach: $parent.columns">
            <!-- ko template: { name: $data.template } -->
            <!-- /ko -->
        </tr>
    </tbody>
</table>

为了让“columntoggle”真正起作用,我目前正在使用“aferRender”事件:

self.tableRowAfterRender = function (element,data) {
    // Skip unless data.Items()[i] is not the last element in the rows collections
    for (var i = 0; i < data.Items().length - 1; i++) {
        if (data.Items()[i] !== self.rows()[self.rows().length - 1].Items()[i])
            return;
    }

    // refresh table after 100ms delay
    setTimeout(function () { $("#report-table").table("refresh"); },100);
}

这是不稳定的,我讨厌setTimeout()做事的方式,这种情况变得安静,我用jquery移动和淘汰赛.我需要一种强大的方法来提升一个事件,一旦所有的淘汰渲染,或理想情况下,一旦所有渲染涉及table-element内的元素完成.我能够在某些情况下使用自定义绑定,但我不知道如何在这里执行此操作.

解决方法

试试这个.用以下内容换行表:< div data-bind ='template:{afterRender:myPostProcessingLogic}'>.然后在myPostProsssingLogic中执行您需要做的任何事情.这只会在首次呈现表时调用.这是一个 fiddle

<div data-bind='template: { afterRender: myPostProcessingLogic }'> 
<table data-role="table" id="report-table" class="ui-body-a ui-shadow ui-responsive table-Stripe"
    data-column-btn-theme="a" data-column-btn-text="Spalten..." data-column-popup-theme="a" data-mode="columntoggle"">
    <thead>
        <tr data-bind="foreach: columns">
            <th data-bind="text: $data.Caption,afterRender: tableRowAfterRender }">
        <tr data-bind="foreach: $parent.columns">
            <!-- ko template: { name: $data.template } -->
            <!-- /ko -->
        </tr>
    </tbody>
</table>

大佬总结

以上是大佬教程为你收集整理的jquery-mobile – 如何在淘汰渲染完成后引发事件?全部内容,希望文章能够帮你解决jquery-mobile – 如何在淘汰渲染完成后引发事件?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。