{"action":"closed","issue":{"url":"https://api.github.com/repos/angular-ui/ui-select/issues/1265","repository_url":"https://api.github.com/repos/angular-ui/ui-select","labels_url":"https://api.github.com/repos/angular-ui/ui-select/issues/1265/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/ui-select/issues/1265/comments","events_url":"https://api.github.com/repos/angular-ui/ui-select/issues/1265/events","html_url":"https://github.com/angular-ui/ui-select/issues/1265","id":112845551,"number":1265,"title":"Cannot read property 'length' of undefined ","user":{"login":"srvee","id":15157791,"avatar_url":"https://avatars.githubusercontent.com/u/15157791?v=3","gravatar_id":"","url":"https://api.github.com/users/srvee","html_url":"https://github.com/srvee","followers_url":"https://api.github.com/users/srvee/followers","following_url":"https://api.github.com/users/srvee/following{/other_user}","gists_url":"https://api.github.com/users/srvee/gists{/gist_id}","starred_url":"https://api.github.com/users/srvee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srvee/subscriptions","organizations_url":"https://api.github.com/users/srvee/orgs","repos_url":"https://api.github.com/users/srvee/repos","events_url":"https://api.github.com/users/srvee/events{/privacy}","received_events_url":"https://api.github.com/users/srvee/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-22T16:51:49Z","updated_at":"2016-03-16T12:12:37Z","closed_at":"2016-03-16T12:12:36Z","body":"Why I am facing this issue?\r\n\r\nCan anyone please help me?\r\n\r\n class=\"btn  btn-primary\" onclick=\"toggleModal()\" \r\n\r\nJS:\r\nfunction toggleModal() {\r\n    var SelectedItems = angular.element(document.getElementById('spin1')).scope().gridOptions1.selectedItems;\r\n  \r\n    if (SelectedItems.length != 0) {    \r\n       \r\n        if (SelectedItems.length == 1) {         \r\n         \r\n            $(\"#dialog\").dialog({\r\n                resizable: true,\r\n                width: 620,\r\n                height: 300,\r\n                modal: true,\r\n                title: 'Duplicate Request',\r\n                buttons: {\r\n                    \"Save\": function () {\r\n                        //$( this ).dialog( \"close\" );\r\n                        var requestprefix = $(\"#inputreq1\").val();\r\n                        var requestyear = $(\"#inputreq2\").val();\r\n                        var requestnumber = $(\"#inputreq3\").val();\r\n                        var Comments = $(\"textarea#Comments\").val();\r\n                        console.log(comments);\r\n                        angular.element(\r\n                            document.getElementById('spin1')\r\n                            ).scope().duplicateRequest(requestprefix, requestyear, requestnumber, Comments,\r\n                            SelectedItems[0]);\r\n                        $(\"textarea#Comments\").val('');\r\n                        $(\"#inputreq1\").val(\"\");\r\n                        $(\"#inputreq2\").val(\"\");\r\n                        $(\"#inputreq3\").val(\"\");\r\n                        alert(\"comments\" + Comments);\r\n                        $(this).dialog(\"close\");\r\n                    }\r\n                }\r\n            });\r\n        }\r\n        else {\r\n            alert(\"Please select only one item for Duplicate Request..\");\r\n        }\r\n    }\r\n    else {\r\n        alert(\"Please select any one item for Duplicate Request..\");\r\n    }\r\n}\r\n\r\n"}}