I have the Table with rows and when I click on add button the Light Box shows the form to add the row.
Now I want to show the newly added row to table and I have two options
-
refresh the whole table so that all the small buttons like `edit/delete’ also gets added to the row
-
Only add the new row. This is good but then again I have to add the edit/delete logic in the template and attach the events to it.
Which way should I go?
You should use
.delegateor.onrather than attach events to all small buttons in the table. And then you do not need to attach the events each time you add a row.Something like
Have a look at jquery .on()