Guest User

Untitled

a guest
Aug 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. _saveAction: function() {
  2.  
  3. // The user must be logged in to Add to BlackBook.
  4. if (User.isLoggedIn()) {
  5. this.saveForm();
  6. } else {
  7. // If not logged
  8. // Display login page
  9. this.trigger('triggerLoginViewToggle');
  10.  
  11. // Listen to successful logins
  12. // Clear previous listeners to prevent double ups
  13. this.stopListening(User, 'userDataLoaded', this.saveForm);
  14. // Continue with form submit when logged in
  15. this.listenToOnce(User, 'userDataLoaded', this.saveForm);
  16.  
  17. // Listen to login view close and remove event if not logged in
  18. this.listenToOnce(User, 'loginViewClosed', function() {
  19. //Don't remove event for sucessfull logins
  20. if (!User.isLoggedIn()) {
  21. this.stopListening(User, 'userDataLoaded', this.saveForm);
  22. }
  23. });
  24. }
  25. },
Add Comment
Please, Sign In to add comment