Implement destroy via @bindCol param.
This commit is contained in:
parent
746f825c8f
commit
1909463c02
1 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
@ -274,7 +278,7 @@ class App.ControllerTable extends App.Controller
|
|||
for event, callback of item.events
|
||||
do (table, event, callback) ->
|
||||
if cursorMap[event]
|
||||
table.find("tbody > tr > td:nth-child(#{position})").css( 'cursor', cursorMap[event] )
|
||||
table.find("tbody > tr > td:nth-child(#{position})").css('cursor', cursorMap[event])
|
||||
table.on( event, "tbody > tr > td:nth-child(#{position})",
|
||||
(e) ->
|
||||
e.stopPropagation()
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue