Search code examples
javascriptexpresshookadmin-bro

Execute script when click Save in Edit page AdminBro


In documentation, AdminBro said that they have predefined action

edit (record action) - update records in a resource

They also have hook after. So I define a function and assign it to MyResource.edit.after. The problem is this function not only execute when I save changes after edit, but also when I go to Edit page, that's not what I want.

How can I run this function only when I click Save Button on Edit page ?


Solution

  • I figured it out. Use before instead of after and compare request.method to POST in parameters