In Laserfiche Forms, when the user adds a row to a table, I'd like to run some Javascript after the row has been added. Is there a straightforward way to do this?
Question
Question
Answer
SELECTED ANSWER
replied on December 1, 2020
•
Show version history
You can assign an onclick event handler to the HTML element of the "Add" button, set a small timeout and run your code inside that timeout.
Example:
$(document).ready(function() { $('.cf-table-add-row').on('click', function() { setTimeout(function() { alert('hello'); }, 50); }); });
If you have multiple tables on the form, you may want to use the `id` of the "add row" element, rather than its class like above.
1
0
replied on December 1, 2020
Thanks, it works. Would it be any more reliable if the timeout were longer--perhaps 200 or 500 instead of 50?
0
0
replied on December 1, 2020
50 milliseconds should be plenty because adding another table row is not very CPU intensive. There are situations where longer timeouts may be desirable but I don't think this is one of those. Depends on what your JavaScript is supposed to be doing of course.
1
0
Replies
You are not allowed to reply in this post.
You are not allowed to follow up in this post.