2013-02-19 125 views
0

我有jquery mobile(knockout)中重複ajax內容的問題。 問題開始時,我打電話回來按鈕開始形式,當我再次調用所有進程。 示例代碼:重複ajax內容

  <div data-role="header" data-theme="c"> 
       <a data-bind="click: headerBackBtn" data-role="button">Back</a> 
       <h1> 
        Header title 
       </h1> 
      </div> 
      <div data-role="content"> 
       <form id="form" name="form" data-bind="visible: form"> 
         <label for="name">Name:</label> 
         <input type="search" name="name" id="name"/> 
         <button data-bind="click: toFirstContent" data-icon="search">Search</button> 
       </form> 

       <!-- first content --> 
       <div class="div-1" id="div-1" data-bind="visible: div-1"> 
        <a data-bind="click: toSecondContent"> 
         Link 
        </a> 
       </div> 

       <!-- second content --> 
       <div class="div-2" id="div-2" data-bind="visible: div-2"> 
        Text 
       </div> 
      </div> 
      <div data-role="footer" data-theme="c"> 
       <h4>footer</h4> 
      </div> 
self.headerBackBtn = function() { 
     if (self.div-2()) { 
      self.div-2(false); 
      self.div-1(true); 
      return; 
     } 
     if (self.div-1()) { 
      self.div-1(false); 
      self.form(true); 
      return; 
     } 
    }; 
+0

我很確定div-1和div -2不是有效的javascript標識符,只是在你的示例代碼中,或者是你的實際代碼的這部分? – 2013-02-19 14:55:50

+0

沒有div id只是例如你可以把div1或div2 – cvelinho 2013-02-19 15:13:15

+0

那麼究竟是什麼問題?我在代碼中看不到ajax調用。 – 2013-02-19 15:30:29

回答

0

解是http://api.jquery.com/remove/。對於每個元素,我把class =「removeItem」,然後調用$(「。removeItem」)。remove(),然後調用函數獲取新元素...