hd.
hd.

Reputation: 18306

Hiding a row on return value from a form in jquery/ajax

I have some data which are loaded to table via jquery/ajax. Table has a column to do delete action on each row.Actions are also done by ajax call and fadingOut the row to hide it from user.

If the user click on delete icon, a dialogbox should be appear to give the reason of removing from user, submission of form should be done by ajax too, and of course the user can cancel this dialogbox, so the row shouldn't fadeOut.

I am confused with these multiple ajax call. How can I get if the user cancel the form or submitted it to determine the need of hiding row?

Upvotes: 0

Views: 89

Answers (2)

kobe
kobe

Reputation: 15835

As you didn't provide the code, I can assume and tell you.

  1. Open the dialog in the context of delete click
  2. Grab the id into some variable to know the context of the row you click
  3. if the user says delete ok , grab the cell by id and fadeOut or remove it or hide it
  4. if the user says cancel, nullify the selection you made for that row.

The main logic is to grab the current cell, which you do by:

$(this).attr('id');

Upvotes: 1

Jon
Jon

Reputation: 437386

You can determine if the user submits or cancels the form by attaching different handlers to the click events of your submit and cancel buttons.

If the cancel button is clicked, the form will not be submitted at all (there will not be an AJAX call) because you won't need to do anything at all.

If you already have code for the dialog box with the form and the AJAX call, post the relevant parts so that we can expand further.

Upvotes: 1

Related Questions