2013-06-04 26 views
1

我在表單末尾使用asp多視圖在提交到sql server之前查看摘要頁面。我的問題是,如果選中了一個複選框,我有幾個顯示/隱藏jQuery函數。那麼,在進入摘要並單擊編輯之後,它會返回並導致.show .hide函數出現一些問題。下面是我使用的一些jQuery代碼。最終,我想保持最終用戶選擇的狀態(選中或不選中)。我是否以這種錯誤的方式去做?在asp.net中使用jQuery .show .hide函數MultiView

如果我選擇不使用asp多視圖,而是使用jQuery .tabs,我將如何從文本輸入中的數據獲取到摘要頁面中的值?

jQuery的

<script type="text/javascript"> 
    function uncheck() { 
     // Uncheck all checkboxes on page load  
     $("input:checkbox:checked").attr("checked", false); 
    } 
    $(document).ready(function() { 
     $('.emsSection').hide(); 
     $('#emsYES').click(function() { 
      $('.emsSection').show(); 
     }); 
     $('#emsNO').click(function() { 
      $('.emsSection').hide(); 
     }); 
     $('.thirdPartyForm').hide(); 
     $('#thirdPartyService').click(function() { 
      var chk = $(this); 
      $('.thirdPartyForm').fadeToggle('fast', chk.attr('checked')); 
     }); 
     $(".phoneMask").mask("(999) 999-9999"); 
    }); 
</script> 

回答

0

嘗試把你的JavaScript函數裏面,而不是頁面加載的的document.ready

這是否解決問題了嗎?

0

我的解決方案是使用jQuery cookie插件。在做了一些研究之後,我通過創建以下內容計算出來:

$(document).ready(function() { 

     $('.thirdPartyForm').hide(); 

     if ($.cookie('showhide') == 'showtp') { 
      $('.thirdPartyForm').show(); 
     } 

     $('#thirdPartyService').click(function() { 
      if ($(this).is(':checked')) { 
       $(".thirdPartyForm").show(); 
       $.cookie('showhide', 'showtp'); 
      } 
      else { 
       $(".thirdPartyForm").hide(); 
       $.cookie('showhide', null); 
      }; 
     }); 
     $('.emsSection').hide(); 

     if ($.cookie('emsservice') == 'showems') { 
      $('.emsSection').show(); 
      } 

      $('#emsYES').click(function() { 
       $('.emsSection').show(); 
       $.cookie('emsservice', 'showems'); 
      }); 
      $('#emsNO').click(function() { 
       $('.emsSection').hide(); 
       $.cookie('emsservice', null); 
     }); 
    });