onRendered 回调

发布于 2024-12-12 08:06:13 字数 301 浏览 0 评论 0原文

我需要实现一个 onRendered() 事件,以确保在执行操作之前渲染所有网格,即 .hide() 它。我的目标是将 .hide().show() 按钮附加到网格所在的 div 上,并具有默认状态设置为隐藏。问题是,在 my 脚本执行初始 .hide() 时,grid.js 脚本尚未完全创建网格。我宁愿不做任何延迟循环。更确切地说有一个回调。

任何帮助将不胜感激

谢谢 拍

I need to implement a sought of onRendered() event that would ensure all of the grid is rendered before I do something, which is to .hide() it. My gaol is to have a .hide() and .show() button attached to the div the grid resides in, with the default status set at hidden. The problem is that at the point in which my script executes the initial .hide(), the grid is not fully created yet by the grid.js script. I would rather not do any delay loop. Much rather have a callback.

Any help would be appreciated

Thanks
Pat

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贪了杯 2024-12-19 08:06:13

这应该可以在没有回调的情况下工作。我有一个 SlickGrid 应用程序,我可以在其中显示和隐藏网格以响应 UI 事件。网格在实例化后立即存在(使用 new Slick.Grid),并且可以使用 .hide().show()方法。

不过,我确实发现了一个问题...

如果您使用 display: none 创建 div 标记(因此它最初是隐藏的),则网格列不会正确初始化。为了解决这个问题,我使用 visibility:hidden 创建 div 标签,并在使用 .hide().show() 方法之前删除此样式。

我的代码大致如下所示:

  <div id="mygrid" style="visibility: hidden"></div>

  $grid = $("#mygrid")

  grid = new Slick.Grid($grid, gridData, gridColumns, gridOptions);

  // Hide grid by default, remembering to remove the visibility style
  $grid.hide();
  $grid.css("visibility", "visible");

  // You can now show and hide the grid using normal jQuery methods
  $grid.show();
  $grid.hide();

希望这有帮助。

This should work without a callback. I have a SlickGrid app where I show and hide the grid in response to UI events. The grid exists as soon as it is instantiated (with new Slick.Grid) and can be manipulated with the .hide()and .show() methods.

I did find one catch though...

If you create the div tag with display: none (so it is initially hidden) the grid columns do not initialise properly. To workaround this I create the div tag with visibility: hidden and remove this style before using the .hide()and .show() methods.

My code looks roughly like this:

  <div id="mygrid" style="visibility: hidden"></div>

  $grid = $("#mygrid")

  grid = new Slick.Grid($grid, gridData, gridColumns, gridOptions);

  // Hide grid by default, remembering to remove the visibility style
  $grid.hide();
  $grid.css("visibility", "visible");

  // You can now show and hide the grid using normal jQuery methods
  $grid.show();
  $grid.hide();

Hope this helps.

戏蝶舞 2024-12-19 08:06:13

slick grid 实现了一个 onRendered 事件 github 源码。我们可以订阅此事件并适当利用它。

The slick grid has implemented an event onRendered event github source. We can subscribe to this event and make the appropriate use of it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文