i’m trying to implement a massive delete action to a list of items, where every item has a checkbox, and there is a button to delete all the selected items. All that in symfony btw.
My biggest problem is: that list with the checkboxes comes from an AJAX call, so i can’t define the listeners in the template where the list is defined. I need to do it in the template that recieves the AJAX response.
i give you some of my code:
- the template returning the list contains:
`
foreach($items as $item){
echo '<input id="'.$item->getItemID().'" type="checkbox" onClick="[I CAN'T REFERENCE HERE A FUNCTION IN THE OTHER TEMPLATE]">';
echo 'etc ...';
}`
- and the template recieving the list is
`
<div id="itemList">
[the AJAX list goes here]
</div>
<input type="button" value="delete all items">`
So my question is: How can i do it to implement that, when the button is pressed, call to for a symfony action with an array of selected checkboxes (or equivalent information) as parameter.
Thank you very much for your time!
The first thing to do is get the array of checkboxes and pass them to the symfony. If you have the following
html:with the following
jquery:See here: http://jsfiddle.net/HbkvF/
Then you do a
executeDeleteBatch()something like (not tested):$countreturns the number of items deleted.