Where is data-win-bindsource?


  • Has this usefull context override option been removed from the current JS base.js binding? Why was that removed?
    Monday, October 08, 2012 4:35 PM


  • It seems that has been removed due to strictProcessing. In the old code you could also not use bindsource in html when strictProcessing was enabled. Since strictProcessing is the default now, the code for bindsource has been removed entirely. 

    A workaround to that is to add a "global" variable to your bindContext object that you hand in processAll like this:
    context = buildYourContext();
    context.global = window;
    WinJS.Binding.processAll(element, context);

    And change your html code from:
    <span data-win-bindsource="mymodel" data-win-bind="innerText:text"></span>
    <span data-win-bind="innerText:global.mymodel.text"></span>

    One could also monkey-patch the WinJS.Binding.processAll like this for the whole app:

    var _processAll = WinJS.Binding.processAll;
    WinJS.Binding.processAll = function(element, context, skipRoot, cache) {
      context.global = window;
      return _processAll(element, context, skipRoot, cache);

    • Marked as answer by phil_ke Tuesday, October 09, 2012 10:08 AM
    Tuesday, October 09, 2012 10:08 AM