2016-08-30 73 views
0

我們在iOS UIWebView中嵌入了一些自定義HTML頁面。我們加載頁面的路徑,然後,所有的腳本都加載到頁面中,一切都很好。除一個之外的所有東西:按鈕的「啓用」狀態。雖然它在Chrome和Safari中100%工作,但一旦嵌入UIWebView,每次按下按鈕時似乎都不會刷新。但我點擊一個字段,然後綁定函數似乎被調用。我使用了Kendo documentation中指定的「啓用」綁定。iOS中的劍道MVVM UIWebView

*工作sample here。如果你使用Safari加載它在iPad上,你會看到這個問題

這裏是我的HTML樣本:

<div class="gui-header-section k-content"> 
     <h1>Test</h1> 
    </div> 
    <div id="recolteInfoDiagnostic"> 
     <div id="section1" data-bind="visible: isSectionVisible(1)"> 
      <div class="gui-form-section k-content"> 
       <div> 
        <form> 
         <ul class="fieldlist"> 
          <li> 
           <label for="fname">First name</label> 
           <input id="fname" data-bind="value: firstNameSousc" class="k-textbox" /></li> 
          <li> 
           <label for="lname">Last Name:</label> 
           <input id="lname" data-bind="value: lastNameSousc" class="k-textbox" /></li> 
          <li> 
           <label>Gender:</label> 
           <select id="cbxGenderSousc" data-bind="source: gendersDataSource, value: genderSousc"></select></li> 
          <li> 
           <label for="agree">License Agreement</label> 
           <input type="checkbox" id="agree" data-bind="checked: agreed" /> 
           I have read the licence agreement</li> 
         </ul> 
        </form> 
       </div> 
      </div> 

      <div class="gui-form-section k-content"> 
       <div> 
        <!-- Some content, ommited for clarity --> 
       </div> 
      </div> 
     </div> 

     <div id="section2" data-bind="visible: isSectionVisible(2)"> 
      <div class="gui-form-section k-content"> 
       <!-- Some content, ommited for clarity --> 
      </div> 

      <div class="gui-form-section k-content"> 
       <!-- Some content, ommited for clarity --> 
      </div> 
     </div> 

     <div id="navToolBar" class="gui-header-section k-content"> 
      <div> 
       <button data-bind="enabled: isBackEnabled, click: back" class="k-button k-primary">Back</button> 
       <button data-bind="enabled: isNextEnabled, click: next" class="k-button k-primary">Next</button> 
      </div> 
     </div> 

    </div> 

而且連同它的JavaScript:

$(document).ready(function() { 

var kendoViewModel = kendo.observable({ 
    formID: "informationsDiagnostic", 
    visibleSectionNo: 1, 
    totalPageNumber: 2, 
    firstNameSousc: "", 
    lastNameSousc: "", 
    genderSousc: "", 
    agreed: false, 

    gendersDataSource = new kendo.data.DataSource({ 
     data: [ 
      { text: "Male", lang: "en", value: "M" }, 
      { text: "Female", lang: "en", value: "F" } 
     ] 
    }), 

    isBackEnabled: function() { 
     return !(this.get("visibleSectionNo") === 1); 
    }, 

    isNextEnabled: function() { 
     return !(this.get("visibleSectionNo") === this.get("totalPageNumber")); 
    }, 

    next: function (e) { 
     e.preventDefault(); 
     this.set("visibleSectionNo", this.get("visibleSectionNo") + 1); 
    }, 

    back: function (e) { 
     e.preventDefault(); 
     this.set("visibleSectionNo", this.get("visibleSectionNo") - 1); 
    }, 

    isSectionVisible: function(pageNumber) { 
     return (pageNumber === this.get("visibleSectionNo")); 
    } 
}); 

$("#cbxGenderSousc").kendoDropDownList({ 
    dataSource: gendersDataSource, 
    dataValueField: "value", 
    dataTextField: "text" 
}).data("kendoDropDownList"); 

kendo.bind($("#recolteInfoDiagnostic"), kendoViewModel); 

});

請注意,「可見」屬性上的數據綁定工作正常,但我無法使其在「已啓用」屬性上正常工作。表單中的所有其他綁定都可以。

回答

0

原來你所要做的就是擺脫按鈕標籤中的「k-primary」風格。