Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // i have some global variables defined which are visible throughout the whole site
- var searchType = ['category_id', 'theme_id', 'mood_id', 'instrument_id'];
- var searchSpeedSelection = '0';
- // these variables _must_ be global, because they are accessed from different JS-functions / event-handlers
- // now i have 2 possibilities:
- // 1. i pass these variables to my event handlers like this:
- jQuery(".foo").click(function(event){
- setTracklistCount(globalSelectionArray, searchSpeedSelection)
- }
- // advantage: it is clearer what is happening
- // 2. i just use them like this:
- jQuery(".foo").click(function(event){
- setTracklistCount();
- }
- // and within "setTracklistCount()" i simply refer to them
- function setTracklistCount(){
- if (searchSpeedSelection.....)
- }
- // advantage: i dont have to pass in a possibly very big list of already global variables
- // disadvantag: less clear
Add Comment
Please, Sign In to add comment