Implement destroy via @bindCol param.

This commit is contained in:
Martin Edenhofer 2015-11-05 17:06:47 +01:00
parent 746f825c8f
commit 1909463c02

View file

@ -9,9 +9,6 @@ class App.ControllerTable extends App.Controller
elements:
'.js-tableHead': 'tableHead'
events:
'click .js-delete': 'deleteRow'
constructor: (params) ->
super
@ -165,6 +162,7 @@ class App.ControllerTable extends App.Controller
attribute.width = "#{@headerWidth[attribute.name]}px"
@headers.push attribute
# add destroy header and col binding
if destroy
@headers.push
name: 'destroy'
@ -174,6 +172,12 @@ class App.ControllerTable extends App.Controller
parentClass: 'js-delete'
icon: 'trash'
if !@bindCol
@bindCol = {}
@bindCol['destroy'] =
events:
click: @deleteRow
if @orderDirection && @orderBy
for header in @headers
if header.name is @orderBy
@ -345,11 +349,10 @@ class App.ControllerTable extends App.Controller
table
# bind on delete dialog
deleteRow: (e) =>
deleteRow: (id, e) =>
e.stopPropagation()
e.preventDefault()
itemId = $(e.target).parents('tr').data('id')
item = @model.find(itemId)
item = @model.find(id)
new App.ControllerGenericDestroyConfirm
item: item
container: @container