locked
WinJS.UI.Repeater built select control displays the last inserted element by default

    Question

  • instead of the first one, like expected.

    var items = ["one","two","three"].map (item) {

      return { title: item }

    }

    WinJS.Namespace.define("data", { items:items});

    Using this in a HTML repeater results in the select control having the "three" visible, but "selectedIndex" is still -1. Whats going on here?

    I can set the select.selectedIndex = 0 but this will not trigger the onchange handler nor will it update the selects "value" property.

    Monday, April 07, 2014 1:42 AM

All replies

  • Can you provide me a working sample for this problem?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, April 07, 2014 7:40 PM
    Moderator
  • Sure, Matt. Will post OneDrive share here soon.
    Monday, April 07, 2014 8:00 PM
  • http://1drv.ms/1nosgrf

    Start the project, you will see "three" in the select, when in fact it should be "one"?

    Wednesday, May 07, 2014 3:38 PM
  • SelectedIndex is -1 because there's actually not a selected item. The displayed item is three, not it's nit selected at this time. You should explicitly set the selectedIndex = 0 and then call the eventhandler yourself if you need to.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, May 09, 2014 5:05 PM
    Moderator