2015-09-26 126 views
-4

你好,我怎樣才能終止功能日期範圍時PARAM淡水河谷不等於javascript函數「日期」如何終止,如果條件滿足

,因爲如果條件得到滿足,並執行功能日期範圍的功能仍然即使如果param運行值不等於「日期」 注意我的代碼是ASP更新面板內

<script type="text/javascript"> 
 
           $(document).ready(function (e) { 
 
            $('.search-panel .dropdown-menu').find('a').click(function (e) { 
 
             e.preventDefault(); 
 
             var param = $(this).attr("href").replace("#", ""); 
 
             var concept = $(this).text(); 
 
             $('.search-panel span#search_concept').text(concept); 
 
             $('[id$=hdnSearchParam]').val(param); 
 
             if (param == "date") { 
 
              $(function daterange() { 
 
               $("#<%= txtsearch.ClientID %>").daterangepicker({ 
 
                locale: { 
 
                 format: 'DD/MMM/YYYY' 
 
                } 
 
               }); 
 
              }); 
 
             } 
 
             else { //terminate the function } 
 

 
            }); 
 
           }); 
 

 
           //Re-Create for on page postbacks 
 
           var prm = Sys.WebForms.PageRequestManager.getInstance(); 
 
           prm.add_endRequest(function daterange() { 
 
            $('.search-panel .dropdown-menu').find('a').click(function (e) { 
 
             e.preventDefault(); 
 
             var param = $(this).attr("href").replace("#", ""); 
 
             var concept = $(this).text(); 
 
             $('.search-panel span#search_concept').text(concept); 
 
             $('[id$=hdnSearchParam]').val(param); 
 
             if (param == "date") { 
 
              $(function() { 
 
               $("#<%= txtsearch.ClientID %>").daterangepicker({ 
 
                locale: { 
 
                 format: 'DD/MMM/YYYY' 
 
                } 
 
               }); 
 
              }); 
 
             } 
 
             else { //terminate the function } 
 
            }); 
 
           }); 
 
          </script>

回答

0

如果即時得到這個權利 - 你試圖以電子郵件xit外部函數 - $(document).ready(function(e){...從事件處理程序中?

我能想到的唯一解決方案是在事件中不處理外部事件時拋出異常。

,如果你願意,你可以檢查此線程:Any way to exit outer function from within inner function?

如果你只是想終止事件處理程序,則沒有必要做anythins,因爲else塊是在處理程序結束,它會無論如何終止。希望這有助於:)