diff --git a/js/index.js b/js/index.js index 800f74f843ba519dceb921bd400100dcf046c1d9..fca834170570f0ed2ba96bf3b0f695e345a3ed2d 100644 --- a/js/index.js +++ b/js/index.js @@ -23,6 +23,8 @@ for (var i = 0; i < users.length; i++) { $userSelector.append('<option value="' + i + '">' + users[i] + '</option>'); } + + updateJoinButtonStatus(); }); }; } @@ -71,6 +73,14 @@ $('.primary-identity-icon').tooltip(); } + /** + * Enable or disable the join button if there are selected users or not. + */ + function updateJoinButtonStatus() { + var selectedUserIndex = $('#user-selector-group select').val(); + $('#send-join-request-btn').prop("disabled", selectedUserIndex === null); + } + // When the document is loaded $(document).ready(function () { @@ -93,6 +103,8 @@ $('#info-message-alert').addClass('hide'); }); + $('#search-user-modal').on('shown.bs.modal', updateJoinButtonStatus); + loadTooltips(); });