Is it possible to pass a list parameter from a browser to a handler function in Snap? How to create a URL with several parameters from a list and send it to a handler function?
For example, I need to delete table rows or any other objects. I cannot do this with the usual REST route:
("/objects/:id", method DELETE deleteObject)
simply because there can be too many, and deleting 100 lines one at a time can be a bit tedious.
I selected the doomed objects by entering a checkbox, say, [3,4,6,8] rows need to be deleted. So how do you pass this list to the handler in the url and what will the route for the action look like?
UPDATE
Ok, I finally did this with jquery and ajax call. The snap function "getParams" can handle multiple parameter URLs, but I still can't figure out how to actually build the URL without jquery and ajax.
I used javascript to collect elements to remove and create an array of elements. Then I used ajax to create the URL of several parameters and send it to the handler. A few things to note with this method and Snap:
- The "getParams" binding function supports only a few old-style URL parameters:
"a=1&a=2&a=3&a=4"
not new:
"a[]=1&a[]=2&a[]=3&a[]=4"
which makes it impossible to transfer complex parameters.
- The route should be:
("/objects/", method DELETE deleteObject)
but not:
("/objects/:ids", method DELETE deleteObject)
I did not answer my question because I do not believe that this is the only way to pass the URL of several parameters with a binding.
Although "getParams" can handle it, my question still remains: how do I create the URL and send it to the handler?
For example, Rails uses the link_to function in presentation logic to create a URL. Snap doesn't use any logic inside the templates, so how does it work? It simply cannot be that the only way to pass multiple parameter URLs in a snap is with javascript ...?
Please confirm this for me?