Skip to content

Commit

Permalink
polluting global window namespace less by defining all grid vars in o…
Browse files Browse the repository at this point in the history
…ne global var window['wiceGrids']
  • Loading branch information
leikind committed Feb 4, 2014
1 parent bdb1f0f commit 7593b98
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vendor/assets/javascripts/wice_grid_init.js.coffee
@@ -1,5 +1,7 @@
$(document).on 'page:load ready', -> initWiceGrid()

globalVarForAllGrids = 'wiceGrids'

initWiceGrid = ->

$(".wice-grid-container").each (index, wiceGridContainer) ->
Expand All @@ -26,7 +28,10 @@ initWiceGrid = ->
templates : filterDeclaration.declaration.templates
ids : filterDeclaration.declaration.ids

window[gridName] = gridProcessor
unless window[globalVarForAllGrids]
window[globalVarForAllGrids] = {}

window[globalVarForAllGrids][gridName] = gridProcessor

setupDatepicker()
setupSubmitReset wiceGridContainer, gridProcessor
Expand Down Expand Up @@ -241,8 +246,8 @@ setupBulkToggleForActionColumn = (wiceGridContainer) ->

getGridProcessorForElement = (element) ->
gridName = $(element).data('grid-name')
if gridName
window[gridName]
if gridName && window[globalVarForAllGrids]
window[globalVarForAllGrids][gridName]
else
null

Expand Down

0 comments on commit 7593b98

Please sign in to comment.