Luci Section Delete button - how to hook?


I have a Luci section:

s = m:section(TypedSection, "application", "Select Application to Add")
-- application is the section called "application" in config file
s.addremove = true
s.sectionhead = "Application"
s.template = "cbi/tblsection"
s.template_addremove = "cbi-select-input-add"
s.add_select_options = select_options

As part of class (because of addremove) , a section "Delete" button is added to section.

My requirements are to hook the Delete (in lua) button such that I can do some preliminary functions prior to section delete.

I need something like "function s.onclick" to hook and then call the regular handler.

Anyone know how to do this, or have a HowTo link?


s = m:section(...)
s.addremove = true

function s.remove(self, sid)
  -- do stuff
  return TypedSection.remove(self, sid)

Wow Jow, quick and helpful response. Here's what I am doing OpenWrt / Lede production application: