diff options
author | winh <winnie@gitlab.com> | 2017-08-01 14:44:17 +0200 |
---|---|---|
committer | winh <winnie@gitlab.com> | 2017-08-01 14:44:17 +0200 |
commit | 4444c098824094ecbedb0cce864711451f79558c (patch) | |
tree | d3f3b71433f705b7df28d772536999fae492401a | |
parent | 5ebafeec04c7c50d06b722f6dd84ba2f91622b3e (diff) | |
download | gitlab-ce-winh-derive-project-name.tar.gz |
Prevent bindEvents if necessary DOM elements are missingwinh-derive-project-name
-rw-r--r-- | app/assets/javascripts/projects/project_new.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/assets/javascripts/projects/project_new.js b/app/assets/javascripts/projects/project_new.js index adea7b7f082..1dc1dbf356d 100644 --- a/app/assets/javascripts/projects/project_new.js +++ b/app/assets/javascripts/projects/project_new.js @@ -26,11 +26,16 @@ const deriveProjectPathFromUrl = ($projectImportUrl, $projectPath) => { }; const bindEvents = () => { + const $newProjectForm = $('#new_project'); const importBtnTooltip = 'Please enter a valid project name.'; const $importBtnWrapper = $('.import_gitlab_project'); const $projectImportUrl = $('#project_import_url'); const $projectPath = $('#project_path'); + if ($newProjectForm.length !== 1) { + return; + } + $('.how_to_import_link').on('click', (e) => { e.preventDefault(); $('.how_to_import_link').next('.modal').show(); @@ -48,7 +53,7 @@ const bindEvents = () => { $('.btn_import_gitlab_project').attr('disabled', !$projectPath.val().trim().length); $importBtnWrapper.attr('title', importBtnTooltip); - $('#new_project').on('submit', () => { + $newProjectForm.on('submit', () => { $projectPath.val($projectPath.val().trim()); }); |