Repository: climate Updated Branches: refs/heads/master 85a4e348d -> 92b0aa3d1
CLIMATE-940 File List Does Not Display On File Selection Due To Property Of Undefined Error Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/e8a2bdc0 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/e8a2bdc0 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/e8a2bdc0 Branch: refs/heads/master Commit: e8a2bdc04153597d490b19a4ccdca47b2dccfabd Parents: 4cf79f3 Author: Michael Anderson <michaelanderson@Michaels-iMac.local> Authored: Wed Jan 3 20:32:11 2018 -0500 Committer: Michael Anderson <michaelanderson@Michaels-iMac.local> Committed: Wed Jan 3 20:32:11 2018 -0500 ---------------------------------------------------------------------- .../directives/predictivefilebrowserinput.js | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/e8a2bdc0/ocw-ui/frontend/app/scripts/directives/predictivefilebrowserinput.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend/app/scripts/directives/predictivefilebrowserinput.js b/ocw-ui/frontend/app/scripts/directives/predictivefilebrowserinput.js index 7142c15..6fe2118 100644 --- a/ocw-ui/frontend/app/scripts/directives/predictivefilebrowserinput.js +++ b/ocw-ui/frontend/app/scripts/directives/predictivefilebrowserinput.js @@ -29,9 +29,16 @@ angular.module('ocwUiApp') .directive('predictiveFileBrowserInput', function() { var link = function($scope, $elem, $attrs) { $scope.autocomplete = []; - + // Set id to use this directive correctly in multiple places - $scope.id = 'autoCompletePath'+ $elem.context.id + /* + This had been written as $elem.context.id, but $elem is an object (jQuery.fn.init) + and the object did not have a context or id attribute. This was + throwing an error to the console and the list of files was not being displayed. + Replaced with $attrs.id. + */ + $scope.id = 'autoCompletePath' + $attrs.id; + /* * We need a place to dump our auto-completion options */ @@ -43,8 +50,8 @@ angular.module('ocwUiApp') var val = $(e.target).text(); $($elem).val(val); // Need to trigger the input box's "input" event so Angular updates the model! - $elem.trigger('input'); - + $elem.trigger('input'); + // If the user selected a directory, find more results.. if (val[val.length - 1] == '/') { $scope.fetchFiles($($elem).val()); @@ -152,7 +159,7 @@ angular.module('ocwUiApp') $scope.possibleCompletes = $scope.autocomplete; }; - /* + /* * Handle <TAB> presses. * * Attempt to auto-complete options when the user presses <TAB>. @@ -220,7 +227,7 @@ angular.module('ocwUiApp') } }; - /* + /* * Handle all other key presses in the input box * * Filter the auto-complete options as the user types to ensure that only options @@ -236,7 +243,7 @@ angular.module('ocwUiApp') $scope.updateAutoComplete(); }; - /* + /* * When a path is auto-completed with <TAB> we need to check to see if it points * to a directory. If it does, we still need to fetch results! */ @@ -247,7 +254,7 @@ angular.module('ocwUiApp') } }; - /* + /* * Calculate the greatest common prefix of the passed options. * * Params: @@ -275,7 +282,7 @@ angular.module('ocwUiApp') return longestString.slice(0, index - 1); }; - /* + /* * Filter the auto-complete options based on the current input. */ $scope.filterResults = function() {