如何显示" loading"经过几次JS?

时间:2016-01-11 16:27:37

标签: javascript jquery asp.net sharepoint loading

我在SharePoint列表上为新表单创建了一个自定义页面。 在这个自定义页面中,我有一个JS函数,它将在Telerik RadComboBox组件中加载文档库的各种文档。 但是我收到了很多文件,表单打开但是并没有给出手,因为整个文档列表都没有收费。 我希望看到一个"正在加载......"由于此表单页面未完全加载,但我无法实现此功能。

我的ASPX表单包含我的RadCombobox:

    <tr>
  <td width="400px" valign="top" class="ms-formbody">
      <telerik:RadListBox  id="rdlFilesForDocument" TransferToID="rdlFilesForDocumentDest" runat="server" 
        AllowTransfer="true" Height="200px" Width="210px" ButtonSettings-AreaWidth="35px" OnClientTransferred="onDocumentTransferred" ButtonSettings-ShowTransferAll="False" />
      <telerik:RadListBox runat="server" ID="rdlFilesForDocumentDest" Height="200px" Width="175px" ButtonSettings-AreaWidth="35px" />
  </td>
</tr>

我的JS会过滤文件:

<script type="text/javascript">
        //Filter Document list with filter
        function filterDocumentList(sender, e) {
            var rdlFilesForDocumentJS = $find("<%= rdlFilesForDocument.ClientID %>");
            var rdcEntityForDocumentJS = $find("<%= rdcEntityForDocument.ClientID %>");
            var rdcYearForDocumentJS = $find("<%= rdcYearForDocument.ClientID %>");
            var rdcTypeForLegalDocumentJS = $find("<%= rdcTypeForDocument.ClientID %>");
            filterList(rdlFilesForDocumentJS, rdcEntityForDocumentJS, rdcYearForDocumentJS, rdcTypeForDocumentJS);
        }

        //Init combobox and fileslistBoxlist
        function pageLoad() {        
            if (!isPostBack) {
                //Init Document files filter and listbox
                var rdlFilesForDocumentJS = $find("<%= rdlFilesForDocument.ClientID %>");
                var rdlFilesForDocumentDestJS = $find("<%= rdlFilesForDocumentDest.ClientID %>");
                var selectDocumentFileFieldResult = $('select[id*=FormField][id*=SelectResult]')[0];
                var rdcEntityForDocumentJS = $find("<%= rdcEntityForDocument.ClientID %>");
                var rdcYearForDocumentJS = $find("<%= rdcYearForDocument.ClientID %>");
                var rdcTypeForDocumentJS = $find("<%= rdcTypeForDocument.ClientID %>");
                initComboBox(rdlFilesForDocumentJS, rdlFilesForDocumentDestJS, selectDocumentFileFieldResult, rdcEntityForDocumentJS, rdcYearForDocumentJS, rdcTypeForDocumentJS, "Documents", entityValue, siteUrl);
            }
            else {
                alert('No Document');
            }
        };
</script>

我怎样才能&#34; Loading&#34;因为我的JS功能还没有完成显示?

我测试过:

$(window).load(function() 
{
   function filterDocumentList(sender, e) {
     //MyFunction....
     }
}); 
Or 
$(document).ready(function()
{
   function filterDocumentList(sender, e) {
     //MyFunction....
     }
}); 

但它没有正常工作,我的文件清单不再收费......

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

看起来你的功能看起来不像。只需使用jQuery函数在页面加载时调用filterDocumentList并隐藏加载消息。

<div class="loading">
  <h1>Loading</h1>
</div>

<script type="text/javascript">

//Filter Document list with filter
function filterDocumentList(sender, e) {
    var rdlFilesForDocumentJS = $find("<%= rdlFilesForDocument.ClientID %>");
    var rdcEntityForDocumentJS = $find("<%= rdcEntityForDocument.ClientID %>");
    var rdcYearForDocumentJS = $find("<%= rdcYearForDocument.ClientID %>");
    var rdcTypeForLegalDocumentJS = $find("<%= rdcTypeForDocument.ClientID %>");
    filterList(rdlFilesForDocumentJS, rdcEntityForDocumentJS, rdcYearForDocumentJS, rdcTypeForDocumentJS);
}
$(function() {
    filterDocumentList();
    $('.loading').hide();
});
</script>