app/assets/javascripts/manage/collection_actions.js.coffee in manage-1.3.17 vs app/assets/javascripts/manage/collection_actions.js.coffee in manage-1.3.18
- old
+ new
@@ -1,28 +1,30 @@
class CollectionActions
constructor: (el) ->
$el = $(el)
- $el.on 'click', 'a', (e) ->
+ $form = $el.closest('form')
+
+ $el.on 'click', (e) ->
e.stopPropagation()
e.preventDefault()
- url = $(@).attr('href')
- requestType = $(@).data('method')
+ checkedCheckboxes = $('.rs:checked')
+ unless checkedCheckboxes.length
+ alert 'Select Items'
+ return false
- # TODO : fetch search form params
- dataParams = []
- $('.rs:checked').each ->
- dataParams.push($(@).attr('value'))
+ # clear all hidden fields with class .hidden_selected_ids
+ $form.find('input[type="hidden"]').remove()
- if dataParams.length == 0
- alert 'Няма направвен избор'
- return false
+ checkedCheckboxes.each ->
+ # create a new hidden
+ hidden_input = $('<input>').attr({
+ type: 'hidden',
+ name: 'selected_ids[]',
+ value: $(@).val()
+ }).appendTo($form)
- $.ajax(
- url: url
- type: requestType
- data: { selected_ids: dataParams }
- ).fail ->
- alert('Възникна грешка')
+ $form.submit()
+
Handlers.register 'CollectionActions', CollectionActions