locked
ListView onselectionchanged not working after Windows RC RRS feed

  • Question

  • This is the listview as seen in the Template:

    <div class="groupeditemslist" aria-label="List of groups" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'single', onselectionchanged : handler}"></div>

    Before the RC i could even set the function handler like this <script>function handler() { /* nothing here */ } </script>

    And would work.. but NOW with the RC it crashes.

    I even tried onselectionchanged: tilesEvents.selectionChanged and in the groupedItems.js i did:

    WinJS.Namespace.define('tilesEvents', {

            selectionChanged: selectionChanged
        });

    AND the still crashes..

    WHYYYYYYYY? 
    boy.. this is really annoying..

    Saturday, June 2, 2012 6:19 PM

Answers

  • The migration white paper advises that 

    any function resolved for data-win-control or as a right-hand-side in data-win-options, or used as a binding initializer in data-win-bind, will require a property on the function definition

    Try this:

    function mySelectionChangedHander(){ //your handler //Your code } mySelectionChangedHandler.supportedForProcessing = true; //Add this after your handler





    Saturday, June 2, 2012 8:12 PM
  • That's correct, any function that's involved in WinJS.UI.processAll or WinJS.Binding.processAll or declarative marktup, including constructors, binding initializers, event handlers, and so forth, must be marked as safe for processing. See the documentation for WinJS.strictProcessing() at http://msdn.microsoft.com/en-us/library/windows/apps/Hh987021.aspx. Note that functions created by WinJS helpers like WinJS.Class.define, WinJS.Binding.initializer, and similar methods will already be marked. You can also use WinJS.Utilities.markSupportedForProcessing (http://msdn.microsoft.com/en-us/library/windows/apps/hh967819.aspx).

    .Kraig

    Saturday, June 2, 2012 11:53 PM

All replies

  • The migration white paper advises that 

    any function resolved for data-win-control or as a right-hand-side in data-win-options, or used as a binding initializer in data-win-bind, will require a property on the function definition

    Try this:

    function mySelectionChangedHander(){ //your handler //Your code } mySelectionChangedHandler.supportedForProcessing = true; //Add this after your handler





    Saturday, June 2, 2012 8:12 PM
  • That's correct, any function that's involved in WinJS.UI.processAll or WinJS.Binding.processAll or declarative marktup, including constructors, binding initializers, event handlers, and so forth, must be marked as safe for processing. See the documentation for WinJS.strictProcessing() at http://msdn.microsoft.com/en-us/library/windows/apps/Hh987021.aspx. Note that functions created by WinJS helpers like WinJS.Class.define, WinJS.Binding.initializer, and similar methods will already be marked. You can also use WinJS.Utilities.markSupportedForProcessing (http://msdn.microsoft.com/en-us/library/windows/apps/hh967819.aspx).

    .Kraig

    Saturday, June 2, 2012 11:53 PM