简体   繁体   English

如何在标签内容完全AJAX加载之前显示加载消息?

[英]How to display a loading message until the tab content is fully AJAX loaded?

I am using jQuery UI 1.10 and the jQuery UI Tab widget with AJAX functionalities. 我正在使用具有AJAX功能的jQuery UI 1.10和jQuery UI Tab小部件。 The JavaScript code that I am using is stated as-like the following (basic simple): 我正在使用的JavaScript代码如下所示(基本简单):

$('.selector').tabs({
  beforeLoad: function (event, ui) {
    ui.panel.html('Loading...');
  }
});

When a tab "header" is clicked then I would like to display a loading message (a text message) in the tab "body" until the tab content is fully AJAX loaded, after which the loading message should be replaced with the AJAX retrieved data. 单击选项卡的“页眉”时,我想在选项卡的“正文”中显示加载消息 (文本消息),直到选项卡的内容完全AJAX加载为止,然后应将加载消息替换为AJAX检索到的数据。 How can I make that? 我该怎么做?

Isn't it working? 不行吗

$('.selector').tabs({
  beforeLoad: function (event, ui) {
    //show msg
  },
  load: function (event, ui) {
    //hide msg
  }
});

You can do this by: 您可以通过以下方式做到这一点:

  1. Define function that 'll load the data via AJAX foreach tab. 定义将通过AJAX foreach选项卡加载数据的函数。
  2. In the tabs callback for show and create you call some function that 'll manage which AJAX function to call to load the right content. showcreate的选项卡回调中,您调用一些函数,该函数将管理调用哪个AJAX函数以加载正确的内容。
  3. Finally inside your AJAX function you first change your html to show the loading message and then when the request is done you can remove it. 最后,在AJAX函数中,首先更改html以显示加载消息,然后在完成请求后将其删除。

it's quite long but it gives you more control on what you want to do. 它很长,但是它可以让您更好地控制自己想做什么。

Best Thing I did was just this for ajax driven tabs...Hope you will love this answer 我做的最好的事情就是使用ajax驱动的标签...希望你会喜欢这个答案

$("#facilityTabContainer").tabs({ panelTemplate:"Loading..." , selected : 0, scrollable : true, cache : false }); $(“#facilityTabContainer”)。tabs({ panelTemplate:“ Loading ...” ,selected:0,scrollable:true,cache:false));

and you can even modify the panelTemplate in jquery.ui.tabs also so that all the tabs in you application will automatically get the 'loading text or image'. 您甚至还可以在jquery.ui.tabs中修改panelTemplate,以便应用程序中的所有选项卡都将自动获取“正在加载文本或图像”。 and guess what it also solves your first tab loading problem too.. 并猜测它还能解决您的第一个标签加载问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有Ajax Toolkit的情况下完全加载gridview之前显示加载图像? - How to display a loading image until a gridview is fully loaded without Ajax Toolkit? 如何在加载 fetch 之前显示加载消息 - How to display loading message until fetch is loaded 如何在下一页内容完全加载之前显示加载或进度条? - How to show loading or progress bar until the next page content fully loaded? AngularJS-内容加载时如何显示消息“ Loading…”? - AngularJS - How to display message “Loading…” while the content is being loaded? 如何防止在对象完全加载到$ scope中之前加载DOM? - How to prevent DOM from loading until object is fully loaded into $scope? 如何隐藏网站内容,直到完全加载? - How to hide website content until it's fully loaded? 如何在 iframe 内容完全加载到 angular 7 之前显示加载程序 - How to show loader until the iframe content fully get loaded in angular 7 如何在图像完全加载之前显示等待gif - How to display a wait gif until image is fully loaded 显示正在加载图像直到div完全加载 - Show Loading image Until div fully loaded 如何显示加载屏幕图像,直到重定向的页面完全加载? - How to display a loading screen image until the redirected page loads fully?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM