{"action":"opened","issue":{"url":"https://api.github.com/repos/knockout/knockout/issues/1871","labels_url":"https://api.github.com/repos/knockout/knockout/issues/1871/labels{/name}","comments_url":"https://api.github.com/repos/knockout/knockout/issues/1871/comments","events_url":"https://api.github.com/repos/knockout/knockout/issues/1871/events","html_url":"https://github.com/knockout/knockout/issues/1871","id":105445103,"number":1871,"title":"(small) Ft. Request: Add $index param to optionsValue/optionsText function","user":{"login":"webketje","id":1928531,"avatar_url":"https://avatars.githubusercontent.com/u/1928531?v=3","gravatar_id":"","url":"https://api.github.com/users/webketje","html_url":"https://github.com/webketje","followers_url":"https://api.github.com/users/webketje/followers","following_url":"https://api.github.com/users/webketje/following{/other_user}","gists_url":"https://api.github.com/users/webketje/gists{/gist_id}","starred_url":"https://api.github.com/users/webketje/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webketje/subscriptions","organizations_url":"https://api.github.com/users/webketje/orgs","repos_url":"https://api.github.com/users/webketje/repos","events_url":"https://api.github.com/users/webketje/events{/privacy}","received_events_url":"https://api.github.com/users/webketje/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-08T18:40:34Z","updated_at":"2015-09-08T18:40:34Z","closed_at":null,"body":"For an application I'm building the **index of an option is more indicative for its value than its display**. The `optionsValue` binding only allows me to access the primitive value from the bound array. One solution is to modify the array values from primitives to small objects, eg. `{value: '...', index: 0}` but I don't like how this pollutes the data model.\r\n````\r\n<select data-bind=\"options: data.options || [], optionsValue: myFunction\">\r\n   <!-- rendered HTML -->\r\n   <option value=\"1\">Select option 1</option>\r\n   <option value=\"2\">Select option 2</option>\r\n   <option value=\"3\">Select option 3</option> \r\n</select>\r\n````\r\n **Currently**, I'm solving it by creating a computed 'dictionary' property, which returns an object with the primitive values as keys, and the indexes as values, and have:\r\n\r\n````\r\nfunction myFunction(item) {\r\n   return self.dictionary[item];\r\n}\r\n````\r\n\r\n**Ideally**, I could have the following in `myFunction`:\r\n````\r\nfunction myFunction(item, index) {\r\n   return index;\r\n}\r\n````\r\nIt would be logical to make this available as is the case for native `Array` functions, as well as some of the `ko.utils`."}}