Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Catalyst client to server interaction

by tangent (Parson)
on Sep 24, 2015 at 15:45 UTC ( #1142930=note: print w/replies, xml ) Need Help??

in reply to Catalyst client to server interaction

Have I got this - when a user clicks on one of the list items a JS function is called to select that item, and if the user then clicks on the Delete button you call another JS function to delete the list item from the DOM, but you also need to actually delete the item on the server?

If correct, then what I would do is, instead of deleting the list item I would hide it or mark it in some way, and also give it a class - say 'for_delete'. Then when the delete button is clicked I would use JS to scan for any list items with the class 'for_delete', collect their ids and then send a request to the server either via an AJAX call or by appending the ids to the form and then submitting the form.

You could re-write your template something like:

[% FOREACH key IN services.keys -%] <li onclick="select(this)" id="[% key %]" class="">service : [% ke +y %] jours de repos: [%services.$key.nb_jours%] interieur : [%service +s.$key.interieur%]</li> [% END -%]
You will also need to give your form a name or an id so you can select it and append the ids.

Replies are listed 'Best First'.
Re^2: Catalyst client to server interaction
by QuillMeantTen (Friar) on Sep 24, 2015 at 16:03 UTC

    many thanks to you sir, or madam, you just saw right through the veils of confusion my own lack of understanding set up around my problem!
    This is the solution I was looking for and I shall set forth on implementing it at once.

      And, wrap the action in an SQL Transaction. (In MySQL, use "InnoDB" tables so that you have transactions.) This way, all deletes will either all occur successfully or none at all.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1142930]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2023-10-03 10:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found