How can I keep checkbox state on a page updated by Ajax?

I have an html table in my application that shows the status of various jobs running on the system. Each task has a state associated with it, for example, a swirly gif for completing tasks. New tasks have a checkbox next to them, which allows the user to select and start the corresponding work.

The table is a struts2 auto refreshing div (sx: div), it is updated every few seconds to reflect what is currently happening with the jobs.

The problem is that when I update the div, I lose this state of the checkboxes.

Is there an elegant way to keep my condition? I have the opportunity to call some javascript after completing the ajax update using the dojo theme system built into the tag, but I'm not sure if this is the best way to approach it.

+3
source share
1 answer

I am not very familiar with the racks, so give me advice on what he stands for.

There are two ways to approach this that I see.

The first (and probably the easiest) is to add the event to the checkboxes, which stores the checked state in an array or onchange object. Then, when you call back from the ajax update, restore these states.

, ajax , , ajax, . ajax "" , .

, javascript , (jquery ..).

+1

Source: https://habr.com/ru/post/1705970/


All Articles