Guest User

Untitled

a guest
Jun 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // i have some global variables defined which are visible throughout the whole site
  2. var searchType = ['category_id', 'theme_id', 'mood_id', 'instrument_id'];
  3. var searchSpeedSelection = '0';
  4. // these variables _must_ be global, because they are accessed from different JS-functions / event-handlers
  5.  
  6. // now i have 2 possibilities:
  7. // 1. i pass these variables to my event handlers like this:
  8.  
  9. jQuery(".foo").click(function(event){
  10. setTracklistCount(globalSelectionArray, searchSpeedSelection)
  11. }
  12.  
  13. // advantage: it is clearer what is happening
  14.  
  15. // 2. i just use them like this:
  16.  
  17. jQuery(".foo").click(function(event){
  18. setTracklistCount();
  19. }
  20. // and within "setTracklistCount()" i simply refer to them
  21.  
  22. function setTracklistCount(){
  23. if (searchSpeedSelection.....)
  24. }
  25. // advantage: i dont have to pass in a possibly very big list of already global variables
  26. // disadvantag: less clear
Add Comment
Please, Sign In to add comment