回答

0

我們結束了使用下面的代碼圖案適合我們的需要的方式來解決這個: -

myapp.AddEditCustomer.Name_postRender = function (element, contentItem) { 
    contentItem.dataBind("_view.isRendered", function (isRendered) { 
     if (isRendered) { 

      var tb = contentItem._view.underlyingControl; 
      tb.getView().on("keyup", ".id-element", null, function (e) { 
       tb.text = tb._textElement.val(); 
      }); 

      contentItem.dataBind("value", function (value) { 
       // Use the toastr library from nuget (http://www.nuget.org/packages/toastr) 
       // in order to display the value of the updated binding target 
       // and demonstrate that the update occurs on PropertyChanged 
       toastr.info("value [" + value + "]"); 
      }); 
     } 
    }); 
}; 

通過利用KEYUP處理器(針對基礎文本框控件的輸入加入的元素)這種方法的力量綁定目標一旦釋放密鑰就進行更新。一旦文本框控件完成渲染,就會附加該鍵控處理程序。

上述示例使用優秀的toastr JavaScript庫(codeseven.github.io/toastr),該庫可以使用關聯的NuGet包(toastr)在Visual Studio中安裝。

相關問題